5

Suppose that:

  1. I have an open source project with a permissive license (MIT or Apache);
  2. This project builds two targets:
    • A library object code file that other, dependent programs would link to;
    • An executable unit test suite that other programs would not link to;
  3. The unit test suite links to a GPL-licensed library;
  4. The library object code that other object code programs would link to does not.
  5. The unit test's source code is embedded in the same source files as the main library code, albeit it's clearly delimited as separate modules from the main library.

Could my project be considered a derived work of the GPL library even if I only use the latter in the test suite? Some details that might be relevant:

  • My library is a collection of random number generators, and it obeys a standard external interface specified by my programming language;
  • The GPL library in question is one that is written for testing random number generators generically (can be used to test any random number generator).
  • I could trivially write a separate, third program that links both my MIT library and the 3rd party GPL one and runs the latter's tests with the output from the former. What linking to the GPL library from my library's unit test suite would do is just automate this and make the process more convenient.
3

When you say that the test code is embedded in the same source, but in different modules, I'm assuming that you mean either they have their own files in the main library or their own classes in the same files of the main library. Either way, they get compiled and released along with the rest of the main library. This means the entire library falls under the GPL.

The easy (and much more sane code wise) solution is to split your tests into a separate library that references both the GPL library and your main lib. This way, you don't have to distribute the tests along with your main lib when you publish the binaries. This will allow you to leave the main lib under whichever license your choose to release it under and your tests get released under the GPL.

  • This is perhaps unclear without going into lots of detail, but the object files for the library do not bundle or link to the GPL library. The compiler does not include the test code in a release build. But I think your suggestion to separate the codebases is indeed a wise one. – Luis Casillas Jul 1 '16 at 0:05
1

Could my project be considered a derived work of the GPL library even if I only use the latter in the test suite?

No. Your test code may be considered as a derivative of your GPL testing library, but not your main code.

And as @RubberDuck suggested, the best way is to make this clear in your code structure that the tests and the main source code are clearly separated and that the dependencies for each are also well separated. Which is not entirely trivial at times in some languages promoting static linking such as Go or Haskell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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