Skip to content

Added test-tidy for dependent licenses. - #12511

Merged
bors-servo merged 1 commit into
servo:masterfrom
asajeffrey:test-tidy-dep-licenses
Jul 21, 2016
Merged

bors-servo merged 1 commit into
servo:masterfrom
asajeffrey:test-tidy-dep-licenses

Conversation

@asajeffrey

@asajeffrey asajeffrey commented Jul 19, 2016 •

Copy link
Copy Markdown
Contributor

Add a test-tidy lint for dependency licenses. Note that #12507 should land first.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes do not require tests because we don't test our lints

This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @wafflespeanut: python/tidy/servo_tidy/licenseck.py, python/tidy/servo_tidy/tidy.py

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jul 19, 2016
@asajeffrey

Copy link
Copy Markdown
Contributor Author

cc @metajack @aneeshusa

Comment thread python/tidy/servo_tidy/tidy.py Outdated
lines = f.read().splitlines(True)
for idx, line in enumerate(lines):
for license in licenses_dep_toml:
ok_licensed |= (license in line)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether license would be a valid name. It's a built-in function :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to license_line.

@asajeffrey

Copy link
Copy Markdown
Contributor Author

BTW, the progress indicator isn't printing correctly:

$ ./mach test-tidy --all
Checking files for tidiness...
  Progress: 100% (9297/9297)
Running the WPT lint...
  Progress: 100% (20057/20057)
Running the dependency licensing lint...
.cargo/git/checkouts/rust-clipboard-4a1584d52df56684/master/Cargo.toml:0: dependency should contain a valid license.
  Progress: 100% (1/1)2)6)

what is the magic I should be using?

Comment thread python/tidy/servo_tidy/licenseck.py Outdated
'license = "MIT / Apache-2.0"',
'license = "MIT OR Apache-2.0"',
'license = "MIT"',
'license = "MIT"',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dupe?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@aneeshusa

Copy link
Copy Markdown
Contributor

The progress_wrapper function needs an iterator as its argument, not a list like filenames, so that it can update the progress each time it yields an object. I'd recommend creating a helper function that yields Cargo.toml files and thus returns an iterator, which can then be consumed by progress_wrapper if progress is True. (See get_wpt_files for an example usage.)

Also, it would be good to have the lint run even if progress is False :)

@ghost

ghost commented Jul 20, 2016

Copy link
Copy Markdown

But, the progress_wrapper converts the iterator into a list again. Let's make progress_wrapper take a list as input (and modify the related methods) instead?

Comment thread python/tidy/servo_tidy/tidy.py Outdated
print '\nRunning the dependency licensing lint...'
for root, directories, filenames in os.walk(".cargo"):
if progress:
filenames = progress_wrapper(filenames)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I missed this. As Aneesh said, this should be

filenames = progress_wrapper(filenames) if progress else filenames

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. (Also fixed the indentation, bah humbug emacs python mode.)

@aneeshusa

Copy link
Copy Markdown
Contributor

@Wafflespeanut I'd prefer to use iterators everywhere (for reduced memory usage), but your call. At the very least, I think we should still accept regular iterators as input to progress_wrapper.

@nox

nox commented Jul 20, 2016

Copy link
Copy Markdown
Contributor

How come do we have to do something similar to grep when we could read the files as TOML files from Python?

@asajeffrey

Copy link
Copy Markdown
Contributor Author

Yay, the progress meter now works!

@asajeffrey asajeffrey added the S-needs-squash Some (or all) of the commits in the PR should be combined. label Jul 20, 2016
@asajeffrey

Copy link
Copy Markdown
Contributor Author

@nox: it would be a bit cleaner to parse the toml file, but would probably use a bit more memory unless there's a clever streaming toml parser out there.

@asajeffrey

Copy link
Copy Markdown
Contributor Author

#12507 has landed, so we should be able to land this one. @larsbergstrom?

@larsbergstrom

Copy link
Copy Markdown
Contributor

Reviewed 2 of 2 files at r3.
Review status: all files reviewed at latest revision, 6 unresolved discussions, some commit checks failed.


Comments from Reviewable

@larsbergstrom

Copy link
Copy Markdown
Contributor

looks good! squash and r=me

@asajeffrey
asajeffrey force-pushed the test-tidy-dep-licenses branch from e003c73 to 536314b Compare July 21, 2016 16:29
@asajeffrey asajeffrey removed S-awaiting-review There is new code that needs to be reviewed. S-needs-squash Some (or all) of the commits in the PR should be combined. labels Jul 21, 2016
@asajeffrey

Copy link
Copy Markdown
Contributor Author

Squashed. @bors-servo r=larsbergstrom

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 536314b has been approved by larsbergstrom

@highfive highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jul 21, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 536314b with merge de4eaa4...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants