Closed
Bug 730807
Opened 13 years ago
Closed 13 years ago
Add a test to testcfx to check for the MPL 2.0 license header
Categories
(Add-on SDK Graveyard :: General, defect, P3)
Tracking
(Not tracked)
RESOLVED
FIXED
1.7
People
(Reporter: wbamberg, Assigned: warner)
References
Details
Attachments
(2 files, 2 obsolete files)
(deleted),
text/plain
|
Details | |
(deleted),
patch
|
wbamberg
:
review+
|
Details | Diff | Splinter Review |
Now we have the MPL 2.0 license statement in every source file, we should have a test added to "testcfx" to make sure files contain it. Otherwise new files will forget to include the license statement.
We'd need the test to skip third-party licensed code such as simplejson.
Reporter | ||
Updated•13 years ago
|
OS: Mac OS X → All
Assignee | ||
Comment 1•13 years ago
|
||
Let's see, at first glance, this should scan all .py files in python-lib/cuddlefish (ignoring the sibling directories), and all .js and .md files in packages/ and examples/ . It's probably sufficient to check that each file contains the URL of the MPL2 (http://mozilla.org/MPL/2.0/) .
Incidentally, I just looked at a random .md file and saw that the english punctuation smushes together with the URL in a potentially bad way:
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
OTOH, going to that URL (which ends in "2.0/." , with a trailing period) immediately redirects to "2.0/", without the period. So we're probably safe, and don't need to edit every single file in the repo to change it to the more-browser-friendly "2.0/ ." .
(In reply to Brian Warner [:warner :bwarner] from comment #1)
> and all .js and .md files in packages/ and examples/ .
Should that be a hardcoded-list of folders in packages? (eg, we don't want to complain to an addon developer who sticks their addons in packages/, right?)
Assignee | ||
Comment 3•13 years ago
|
||
oh, good point.. added that.
This patch scans python-lib/cuddlefish and
packages/{addon-kit,api-utils,test-harness}, looking for .js and .py files,
and grepping each for the MPL2 URL. It has an exception for _version.py
(which is generated from an upstream tool, and in the public domain).
Does that set of files sound right?
It currently flags 17 files:
% python python-lib/cuddlefish/tests/test_licenses.py -v
test (__main__.Licenses) ...
The following files are missing an MPL2 header:
packages/api-utils/data/worker.js
packages/api-utils/tests/test-process.js
packages/api-utils/tests/test-uuid.js
python-lib/cuddlefish/docs/__init__.py
python-lib/cuddlefish/docs/webdocs.py
python-lib/cuddlefish/packaging.py
python-lib/cuddlefish/templates.py
python-lib/cuddlefish/tests/bug-588119-files/packages/explicit-icon/lib/main.js
python-lib/cuddlefish/tests/bug-588119-files/packages/implicit-icon/lib/main.js
python-lib/cuddlefish/tests/bug-588119-files/packages/no-icon/lib/main.js
python-lib/cuddlefish/tests/bug-588661-files/packages/bar/lib/bar-loader.js
python-lib/cuddlefish/tests/bug-588661-files/packages/foo/lib/foo-loader.js
python-lib/cuddlefish/tests/linker-files/three/tests/nontest.js
python-lib/cuddlefish/tests/linker-files/three/tests/test-one.js
python-lib/cuddlefish/tests/linker-files/three/tests/test-two.js
python-lib/cuddlefish/tests/preferences-files/packages/no-prefs/lib/main.js
python-lib/cuddlefish/tests/preferences-files/packages/simple-prefs/lib/main.js
FAIL
======================================================================
FAIL: test (__main__.Licenses)
----------------------------------------------------------------------
Traceback (most recent call last):
File "python-lib/cuddlefish/tests/test_licenses.py", line 31, in test
self.fail("%d files are missing an MPL2 header" % len(self.missing))
AssertionError: 17 files are missing an MPL2 header
----------------------------------------------------------------------
Ran 1 test in 0.074s
FAILED (failures=1)
Next, I'll go through those files and add the headers. If you think it's
missing some files, let me know, I'll update the scanner. Alternatively, if
you think that tests/ (specifically python-lib/cuddlefish/tests/) aren't
worth scanning, I can exclude those.
Reporter | ||
Comment 4•13 years ago
|
||
> It currently flags 17 files:
I'm surprised it flags so many old files. But it's right. I assume they were just missed in bug 715558, unless there's some reason for excluding them that I don't see.
> Next, I'll go through those files and add the headers. If you think it's
> missing some files, let me know, I'll update the scanner.
We also include the license declaration for:
- all MD files for the built-in packages under /packages
- JS, CSS, and MD files under /doc except syntaxhighlighter, which is third-party
- PY files under /python-lib/mozrunner
- batch files under /bin
- JS, CSS, HTML, and MD files under /examples
Assignee | ||
Comment 5•13 years ago
|
||
Ok, I updated the scanner to include your notes. This attachment has a list of all the files that were scanned: does it look complete?
(I had to exclude (three distinct copies of) jquery.js too)
Assignee | ||
Comment 6•13 years ago
|
||
and here's the updated scanner patch. Still doesn't include the actual MPL2 additions.
Attachment #601476 -
Attachment is obsolete: true
Assignee | ||
Comment 7•13 years ago
|
||
also, mozrunner/killableprocess.py and winprocess.py already have their own license headers, looks like MIT or maybe BSD, so I guess I'll add those to the skip list
Assignee | ||
Comment 8•13 years ago
|
||
I added MPL2 headers to everything the tool spotted, but found four exceptions.. what should we do with them?:
* examples/library-detector/data/library-detector.js : says it's adapted from an MIT licensed original
* packages/api-utils/tests/test-process.js: has a MPL1.1/GPL2.0/LGPL2.1 tri-license header
* python-lib/mozrunner/killableprocess.py: has a header, looks like it comes from python, looks BSDish
* python-lib/mozrunner/winprocess.py: very similar, but says "The MIT License"
Reporter | ||
Comment 9•13 years ago
|
||
Gerv, I wonder if you could help us out here?
Some SDK files didn't get an MPL 2.0 license statement, back in bug 715558. While some of those files are clearly third-party and should keep their original license, some seem to be original (for instance, the list in comment 3 above). I'm not sure whether this was intentional or not.
Also, the four Brian's noted in comment 8 seem questionable - I'd guess that original files should be MPL 2.0, while any derived files should keep their original license. Meaning that these:
> * examples/library-detector/data/library-detector.js : says it's adapted
> from an MIT licensed original
> * python-lib/mozrunner/killableprocess.py: has a header, looks like it comes
> from python, looks BSDish
> * python-lib/mozrunner/winprocess.py: very similar, but says "The MIT
> License"
... should keep their original license, but this:
> * packages/api-utils/tests/test-process.js: has a MPL1.1/GPL2.0/LGPL2.1
> tri-license header
...should be upgraded to the MPL 2.0. But some expert help would be great.
Comment 10•13 years ago
|
||
I didn't intentionally exclude any files apart from externally-sourced files. So if I missed a tri-licensed file, that was an accident and you should feel free to fix it.
Files sourced from elsewhere should keep their original licence.
So comment 9 seems right to me.
Gerv
Updated•13 years ago
|
Priority: -- → P3
Assignee | ||
Comment 11•13 years ago
|
||
Ok, here's the final patch. It adds the test_licenses.py (with a list of files/directories being skipped), adds MPL2 headers to the files that don't have it, and updates that one MPL1/tri-licensed file to MPL2. (the actual git branch has these in three separate patches, but this diff submitted for review collapses them all together)
Attachment #601679 -
Attachment is obsolete: true
Attachment #602054 -
Flags: review?(wbamberg)
Reporter | ||
Comment 12•13 years ago
|
||
Comment on attachment 602054 [details] [diff] [review]
grep most SDK files for an MPL2 URL, add MPL2 where necessary
Looks good to me, thanks Brian!
In "test_licenses.py" lines 73-74 are commented-out code and should probably be removed. It might be helpful to have a comment block in there describing what's covered by the test, since it's a bit obscure.
Attachment #602054 -
Flags: review?(wbamberg) → review+
Comment 13•13 years ago
|
||
Commits pushed to master at https://github.com/mozilla/addon-sdk
https://github.com/mozilla/addon-sdk/commit/78eaa8a99150d3b9167c633070d1f432394e70bd
Bug 730807: test that all appropriate SDK files have an MPL2 header
Some specific files are skipped because they have their own non-MPL2 license
headers. A list of these files are included at the top of test_licenses.py .
Only specific directories are scanned. In particular, some third-party
libraries (used under other licenses) in python-lib are skipped, as is the
"syntaxhighlighter" JS library. We also skip any additional packages added to
packages/ .
https://github.com/mozilla/addon-sdk/commit/adb36f0119d52da317004fbc23e5a088da6f31e5
Bug 730807: test that all appropriate files have an MPL2 header. r=@wbamberg
Assignee | ||
Comment 14•13 years ago
|
||
Great, landed with your recommended changes.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → 1.7
You need to log in
before you can comment on or make changes to this bug.
Description
•