pants: target sources glob expansion failure warning needs followup work
In #5769, we added a warning, or an error, if any of the elements in a globs(), rglobs(), zglobs(), or a literal file list provided as a sources= or bundles= keyword argument in a target definition. We pull in the logging crate to perform the warning, but the macro provided (warn!()) doesn’t seem to print anything anywhere I can find (although eprintln!() works!).
As a result of that PR, using --glob-expansion-failure=warn should use warn!() to describe to the user what target and what argument was being hydrated when a glob was expanded to nothing. This is done with --glob-expansion-failure=error by simply raising, producing the great native engine stack trace, e.g.:
Exception message: Build graph construction failed: ExecutionError Received unexpected Throw state(s):
Computing Select(Specs(dependencies=(SingleAddress(directory=u\'testprojects/src/python/sources\', name=u\'some-missing-some-not\'),)), =TransitiveHydratedTargets)
Computing Task(transitive_hydrated_targets, Specs(dependencies=(SingleAddress(directory=u\'testprojects/src/python/sources\', name=u\'some-missing-some-not\'),)), =TransitiveHydratedTargets)
Computing Task(transitive_hydrated_target, testprojects/src/python/sources:some-missing-some-not, =TransitiveHydratedTarget)
Computing Task(hydrate_target, testprojects/src/python/sources:some-missing-some-not, =HydratedTarget)
Computing Task(hydrate_sources, SourcesField(address=BuildFileAddress(testprojects/src/python/sources/BUILD, some-missing-some-not), arg=sources, filespecs={u\'exclude\': [], u\'globs\': [u\'*.txt\', u\'*.rs\']}), =HydratedField)
Computing Snapshot(Key(val="PathGlobs(include=(u\\\'testprojects/src/python/sources/*.txt\\\', u\\\'testprojects/src/python/sources/*.rs\\\'), exclude=(), glob_match_error_behavior=\\\'error\\\')"))
Throw(PathGlobs expansion failed: Throw(Globs did not match. Excludes were: []. Unmatched globs were: ["testprojects/src/python/sources/*.rs"]., "<pants native internals>"))
Traceback (no traceback):
<pants native internals>
Exception: PathGlobs expansion failed: Throw(Globs did not match. Excludes were: []. Unmatched globs were: ["testprojects/src/python/sources/*.rs"]., "<pants native internals>")
However, the warning message we currently display would only contain the end of that: Globs did not match. Excludes were: []. Unmatched globs were: ["testprojects/src/python/sources/*.rs"].. This needs to be fixed for --glob-expansion-failure=warn to be usable.
There are multiple unit tests to unskip in tests/python/pants_test/engine/legacy/test_graph_integration.py once these are resolved. This was left as a FIXME in that PR.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (16 by maintainers)
@cosmicexplorer I think this can now be closed? Rust logging has changed quite a bit the past year thanks to @blorente and we recently made the warning message far more helpful.