ericphanson / ExplicitImports.jl

Developer tooling for Julia namespace management: detecting implicit imports, improper explicit imports, and improper qualified accesses
https://ericphanson.github.io/ExplicitImports.jl/
MIT License
62 stars 2 forks source link

Extension to ```runtests.jl``` in the /test dir #19

Closed ctkelley closed 3 months ago

ctkelley commented 3 months ago

This package is great stuff. Is there a way to run it on the runtests.jl script you use for CI?

ericphanson commented 3 months ago

Yep! You can add it as a test dependency, and then use these functions in your tests: https://ericphanson.github.io/ExplicitImports.jl/stable/api/#Usage-in-testing

ctkelley commented 3 months ago

That's not exactly what I had in mind. My runtests.jl file is not a module, but begins with several using statements. Can I figure out what the implicit imports in my test suite are?

ericphanson commented 3 months ago

Ah I see. You could try: print_explicit_exports(Main, "test/runtests.jl"). Let me know if that works, maybe we can document it or add a shortcut for main.

ctkelley commented 3 months ago

Thanks!

I assume you meant

print_explicit_imports(Main, "test/runtests.jl")

That did the job, but then I got several things about Base. Several lines of stuff like this.

Module Base is not relying on any implicit imports.

Module Base.GMP.MPQ is not relying on any implicit imports.

Module Base.StackTraces is not relying on any implicit imports.

Module Base.__toplevel__ is not relying on any implicit imports.

Module Base.Ryu is not relying on any implicit imports.
ericphanson commented 3 months ago

Ok good to know, we can probably provide a “script” entry point that can filter stuff like that out and be usable for this

ericphanson commented 3 months ago

The reason Base shows up is basically https://github.com/JuliaLang/julia/issues/53574. But we can filter it out manually.

ericphanson commented 3 months ago

v1.2 is out with print_explicit_imports_script that should cover this! Let me know if you run into issues.

ctkelley commented 3 months ago

That did the job. Thanks for responding to this so fast.