Repository navigation
Report an error when run_script is given a directory of no size - #1853
Merged
Merged
Conversation
run_script takes a file of size zero for an empty script, which is not an error, and found a directory to be one only when opening it failed. A directory can report a size of zero too. Then run_script printed nothing and set last_result to True. This showed in CI as test_run_script_with_invalid_file failing on Windows with Python 3.12 and 3.14 and passing in the other four Windows jobs, and in the same two when they were run again: Windows reported that size for the tests directory in some jobs and not in others. Why it did is not known. run_script now looks for a directory first, so its answer no longer depends on the size. The message for a directory says that it is one, where it used to give the operating system's error for opening it.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1853 +/- ##
=======================================
Coverage 99.76% 99.76%
=======================================
Files 23 23
Lines 6767 6770 +3
=======================================
+ Hits 6751 6754 +3
Misses 16 16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Found in review. Where the temporary directory's path has a space, the command was parsed as several arguments, and argparse printed its usage before run_script looked at the directory. The path is now quoted, so the test passes or fails for what it tests wherever it runs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
run_scriptgiven a directory which reports a size of zero printed nothing and setlast_resulttoTrue. It now reports an error.The cause
do_run_scripttakes a file of size zero for an empty script, which is not an error, and returns. It found a directory to be one only later, when opening it failed. A directory can report a size of zero too, and then the early return is taken.How it showed
test_run_script_with_invalid_filerunsrun_scripton the directory the tests are in. On #1849 it failed on Windows with Python 3.12 and 3.14, with no error printed for the directory, and passed in the other four Windows jobs of the same run. The two failed jobs passed when run again on the same commit (run 46730357548). None of the 29 failed runs of the Tests workflow before it, back to mid-November, failed in this test.The code in question is the same on
main, so the same failure can happen here.Not known: why Windows reported a size of zero for that directory in two jobs and not in the others. The fix does not depend on the answer.
The change
run_scriptlooks for a directory before anything else and reportsProblem accessing script from '<path>': it is a directory. The text after the colon used to be the operating system's error for opening a directory, which on POSIX is[Errno 21] Is a directory.test_run_script_with_directory_of_no_size, makesos.path.getsize()return zero and runsrun_scripton a directory. Before the fix it fails with the sameIndexErrorat the same assertion as in CI; after it, it passes.Evidence
On macOS,
make check,make test(3,212 passed, 3 skipped) andmake docs-testpass. Not run on Windows other than by CI on this PR.