Skip to content

Python: Add example of top-level module shadowing stdlib#4655

Closed
RasmusWL wants to merge 2 commits into
github:mainfrom
RasmusWL:python-add-import-test-shadowing-stdlib
Closed

Python: Add example of top-level module shadowing stdlib#4655
RasmusWL wants to merge 2 commits into
github:mainfrom
RasmusWL:python-add-import-test-shadowing-stdlib

Conversation

@RasmusWL

Copy link
Copy Markdown
Member

Although this test is added under the wrong folder, the current results from this CodeQL test is actually correct (compared with the Python interpreter). However, they don't match what the extractor does when invoked with codeql database create. I want to use this test-case as a reference, when updating the tool invocation from our testing setup to match what happens in the extractor.

It would be better to just fix the extractor, but that is not trivial, since it requires us to correctly guess the root of source-code in a project (so we can simulate it becoming the first element of sys.path). Making the behavior of our testing setup the same as the production environment is a step in the right direction in my opinion (even if that means having the same known problems).

Inspired by the debugging in #4640

Although this test is added under the `wrong` folder, the current results from
this CodeQL test is actually correct (compared with the Python
interpreter). However, they don't match what the extractor does when invoked
with `codeql database create`. I want to use this test-case as a reference, when
updating the tool invocation from our testing setup to match what happens in the
extractor.

It would be better to just fix the extractor, but that is not trivial, since it
requires us to correctly guess the root of source-code in a project (so we can
simulate it becoming the first element of `sys.path`). Making the behavior of
our testing setup the same as the production environment is a step in the right
direction in my opinion (even if that means having the same known problems).

Inspired by the debugging in github#4640
@RasmusWL RasmusWL requested a review from a team as a code owner November 11, 2020 15:14
@RasmusWL RasmusWL marked this pull request as draft November 12, 2020 09:57
@RasmusWL

Copy link
Copy Markdown
Member Author

Converted to draft, since I don't want this merged before we decide on what order to merge extractor change and this PR in.

@RasmusWL

Copy link
Copy Markdown
Member Author

Made internal changes to extractor that is used by codeql test run, and retriggered the tests. Hopefully they will fail now 🤞

@yoff

yoff commented Nov 13, 2020

Copy link
Copy Markdown
Contributor

🎉

@RasmusWL

Copy link
Copy Markdown
Member Author

Note that the tests did indeed fail after the internal extractor change was merged, but we had to revert that change since it broke a lot of our existing tests (and we didn't notice initially).

Changing the way qltest invokes the extractor was a bit of a challenge, and there are more important things to do right now... so manually changing the test to do the same as codeql database create, and creating internal tracking issue to change the qltest extractor behavior in general.

@RasmusWL RasmusWL marked this pull request as ready for review November 18, 2020 11:19
Changing the way qltest invokes the extractor was a bit of a challenge, and
there are more important things to do right now... creating an internal tracking
issue for this instead.
@RasmusWL RasmusWL force-pushed the python-add-import-test-shadowing-stdlib branch from 7cb6641 to 62b7fdd Compare November 18, 2020 12:30
@RasmusWL

Copy link
Copy Markdown
Member Author

This PR has turned into a disaster. I'm closing it, to start from scratch, and will pretend it never happened.

@RasmusWL RasmusWL closed this Nov 19, 2020
@RasmusWL RasmusWL deleted the python-add-import-test-shadowing-stdlib branch November 19, 2020 12:34
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.

2 participants