google / licensecheck

The licensecheck package classifies license files and heuristically determines how well they correspond to known open source licenses.
BSD 3-Clause "New" or "Revised" License
452 stars 75 forks source link

licensecheck: add Trace function #35

Open jba opened 3 years ago

jba commented 3 years ago

Add the Trace function, which sets the match.TraceDFA variable.

This is invaluable for debugging uses of this package.

As one example, you are faced with what seems to be a fine Apache-2.0 license that nonetheless isn't matched by any LRE. You try to compare the text to the LRE, but quickly realize that this task is toilsome and inaccurate. Calling Trace and running again immediately reveals that someone has s/product/bundle/, resulting in "reproduction" being altered to "rebundleion". (True story.)

Trace is also useful when writing custom LREs to capture new license variants.

rsc commented 3 years ago

FWIW the expectation was that you'd do this by adding a test case to package licensecheck and then using

go test -tracedfa=N -run=Testdata/yourfile

Does that work in your context?

jba commented 3 years ago

It does, and I was doing that. But it seems wrong to have to modify licensecheck when I'm debugging my own custom LREs, not ones I plan to add to the licensecheck corpus.