Skip to content

gh-109295: Skip test_generated_cases if different mount drives #109308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2023

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Sep 12, 2023

On Windows, skip the test if the current working directory and the Python source code directory have different mount drives. It happens if the temporary directory is on a different mount drive than the Python source code.

On Windows, skip the test if the current working directory and the
Python source code directory have different mount drives. It happens
if the temporary directory is on a different mount drive than the
Python source code.
@vstinner vstinner force-pushed the test_generated_cases branch from 7f10fe4 to 4ad15ef Compare September 12, 2023 01:58
@vstinner
Copy link
Member Author

Example without the fix:

vstinner@WIN C:\victor\python\main>cd
C:\victor\python\main

vstinner@WIN C:\victor\python\main>python -m test test_generated_cases --tempdir=E:\TEMP\ -j1
Running Debug|x64 interpreter...
0:00:00 Run tests in parallel using 1 child processes
0:00:00 [1/1/1] test_generated_cases failed (uncaught exception)
test test_generated_cases crashed -- Traceback (most recent call last):
  (...)
  File "C:\victor\python\main\Lib\test\test_generated_cases.py", line 11, in <module>
    import generate_cases
  File "C:\victor\python\main\Tools\cases_generator\generate_cases.py", line 41, in <module>
    DEFAULT_INPUT = os.path.relpath(os.path.join(ROOT, "Python/bytecodes.c"))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\victor\python\main\Lib\ntpath.py", line 791, in relpath
    raise ValueError("path is on mount %r, start on mount %r" % (
ValueError: path is on mount 'C:', start on mount 'E:'

== Tests result: FAILURE ==

1 test failed:
    test_generated_cases

Total duration: 793 ms
Total tests: run=0
Total test files: run=1/1 failed=1
Result: FAILURE

With the fix:

vstinner@WIN C:\victor\python\main>cd
C:\victor\python\main

vstinner@WIN C:\victor\python\main>python -m test test_generated_cases --tempdir=E:\TEMP\ -j1
Running Debug|x64 interpreter...
0:00:00 Run tests in parallel using 1 child processes
0:00:00 [1/1] test_generated_cases skipped
test_generated_cases skipped -- the current working directory and the Python source code directory have different mount drives (E: and C:)

== Tests result: SUCCESS ==

1 test skipped:
    test_generated_cases

Total duration: 613 ms
Total tests: run=0
Total test files: run=1/1 skipped=1
Result: SUCCESS

@vstinner vstinner merged commit 9363769 into python:main Sep 12, 2023
@vstinner vstinner deleted the test_generated_cases branch September 12, 2023 02:30
@vstinner vstinner added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Sep 12, 2023
@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington
Copy link
Contributor

Sorry, @vstinner, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 936376916100681d46db117bae0ec05adf338051 3.11

@miss-islington
Copy link
Contributor

Sorry, @vstinner, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 936376916100681d46db117bae0ec05adf338051 3.12

@vstinner vstinner removed needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Sep 12, 2023
@vstinner
Copy link
Member Author

Python 3.11 and 3.12 are not affected: Lib/test/test_generated_cases.py is new in Python 3.13.

@vstinner
Copy link
Member Author

An alternative would be to change the current working directory while testing test_generated_cases, as done by test_pyexpat: #109233

But the problem is that the directory should be changed early when test_generated_cases.py is imported, before the first Tools/cases_generator/ import, and the old directory should be restore "later". But when is "later"? After the import? And then change again cwd while running tests using setUpModule()/tearDownModule()?

Well, for me it was too complicated, and I made the minimum fix: just skip the test.

vstinner added a commit to vstinner/cpython that referenced this pull request Sep 13, 2023
…ython#109308)

On Windows, skip the test if the current working directory and the
Python source code directory have different mount drives. It happens
if the temporary directory is on a different mount drive than the
Python source code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants