8

Let's say I'm working on a software library in which certain unit tests rely on GPL licensed code but the code that a user of this library would install on their system does not interact with GPL licensed code.

Do I still have to licence all of the library's code under the GPL? Or can I provide separate licences for my tests and the rest of my code?

If someone who clones my project repository builds the tests (which is optional), the tests are linked against a GPL (without library exception) licensed shared library as runtime. This is the only part of my library that uses GPL'd software in any way. I'm uncertain whether this makes the whole library fall under the GPL because the tests are distributed as part of the same project.

0

3 Answers 3

9

Merely using GPL-covered software is perfectly fine under any circumstance. The question is whether software that you wrote is also covered by the GPL. This is the case whenever it is a derivative work of GPL-covered software as defined by copyright law, in particular if the software that you distribute is a modified version of GPL-covered software or if your software includes GPL-covered code.

In the description of your software, you have mentioned or implied the following components and relationships:

project components

  • you have a repository containing source code for the library and for the tests
  • the tests need a GPL library to run

Clearly, the library source code is not a derivative work of the GPL-covered library. Therefore, you cannot be forced to release the library source code or binaries of the library under the GPL. Similarly, the source code of the tests is (likely) not derivative of the GPL-covered library.

However, the runnable tests are probably derivative of the GPL-covered library. Under the terms of the GPL, the source code of your runnable tests must be made available in compliance with the GPL, in particular under a GPL-compatible license. The source code of the tests includes the library's source code.

(You do not actually distribute the runnable tests but only their source code. In my amateur opinion, this difference is not material to this licensing discussion. Assume the runnable tests were licensed in a way so that they could not be distributed under the terms of the GPL. Whether the runnable tests would be distributed (thus committing copyright infringement) or whether you would merely distribute all the parts necessary to create the runnable tests (thus likely committing contributory copyright infringement) – I doubt this would be legal.)

To summarize, this means:

  • You are not required to publish your tests.
  • If you publish the tests in source form or other form, you must make the source code of the runnable tests under a GPL-compatible license.
  • The source code of the tests includes the source code of your main library.
  • You can choose different licenses for the libraries and the tests, as long as all licenses are compatible with each other.
  • While the license that you choose has to be GPL-compatible, it does not have to be the GPL itself. For example, you could choose the MIT license instead. This should not be a problem for most open source libraries.

There are some niche cases where there would be problems. For example, if you publish the library incl. tests under a license that is not GPL-compatible. Another scenario would be a proprietary software project where you do not intend to share the tests at all, but would later like to license your test suite to a client. This would imply a license of the main library to the client under a GPL-compatible license.

Note that the set of GPL-compatible licenses depends on the exact GPL version. In particular, the Apache 2 license is compatible with GPLv3 but not GPLv2. See the FSF license list for various licenses and the FSF's thoughts on GPL compatibility.

1
  • "Merely using GPL-covered software is perfectly fine under any circumstance." Hence the "running a SaaS server" loophole?
    – nick012000
    Dec 12, 2019 at 7:50
4

Merely using software in the course of creating other software doesn't make it a derivative work. Otherwise, you would be subject to the licenses of even things like the operating system your compiler ran on! You can safely license your code separately from your tests.

In fact, depending on the details, it's possible you may not even need to GPL license your tests. For example, if you do not distribute your tests, they wouldn't need to be GPL licensed.

2
  • I guessing the OP means he is using GPL software as libraries employed by his tests, rather than e.g. simply using a GPL licensed test runner. In the case his software uses GPL libraries, I think the answer is "definite maybe" a.k.a. off-topic. In any case the OP should elaborate. Oct 18, 2018 at 22:37
  • Your reasoning about compilers and OSes may be flawed. The GPLv3 explicitly exempts dependencies on operating systems and compilers (→ “System Libraries”)”. Similarly, GPLv2 excludes major components of an OS from its definition of source code. For example, this would allow me to port a GPL-covered software so that it depends on Windows-only APIs and only builds with Visual Studio. However, these sections of the GPL might only be included for the avoidance of doubt, without being legally necessary.
    – amon
    Oct 20, 2018 at 14:29
3

The GPL does not require you to put the tests under GPL unless you distribute the executables linked with the GPL code. You should disribute the tests as source code, and let the customer find his own copy of the GPL code and compile and link them together to perform the tests himself.

As long as you don't do anything even resembling distributing a version linked with the GPL code, you should be OK.

Just to be sure, don't even distribute the GPL code with your system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.