Skip to content

Commit b435f6d

Browse files
committed
Skip tests that pollute the execution environment for some reason
1 parent 4c76eef commit b435f6d

File tree

7 files changed

+56
-12
lines changed

7 files changed

+56
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,32 @@ env:
105105
test_unpack
106106
test_weakref
107107
test_yield_from
108+
ENV_POLLUTING_TESTS_COMMON: >-
109+
test_raise
110+
test_ssl
111+
test_sys
112+
ENV_POLLUTING_TESTS_LINUX: >-
113+
test.test_multiprocessing_fork.test_processes
114+
test.test_multiprocessing_fork.test_threads
115+
test.test_multiprocessing_forkserver.test_processes
116+
test.test_multiprocessing_forkserver.test_threads
117+
test.test_multiprocessing_spawn.test_processes
118+
test.test_multiprocessing_spawn.test_threads
119+
test_file_eintr
120+
test_subprocess
121+
ENV_POLLUTING_TESTS_MACOS: >-
122+
test_multiprocessing_forkserver.test_manager
123+
test.test_multiprocessing_forkserver.test_misc
124+
test.test_multiprocessing_forkserver.test_processes
125+
test.test_multiprocessing_forkserver.test_threads
126+
test.test_multiprocessing_spawn.test_manager
127+
test.test_multiprocessing_spawn.test_misc
128+
test.test_multiprocessing_spawn.test_processes
129+
test.test_multiprocessing_spawn.test_threads
130+
test_ftplib
131+
test_logging
132+
test_multiprocessing_main_handling
133+
test_subprocess
108134
# Python version targeted by the CI.
109135
PYTHON_VERSION: "3.13.1"
110136

@@ -292,26 +318,47 @@ jobs:
292318

293319
- if: runner.os == 'Linux'
294320
name: run cpython platform-independent tests
321+
env:
322+
RUSTPYTHON_SKIP_ENV_POLLUTERS: true
295323
run:
296324
target/release/rustpython -m test -j 1 -u all --slowest --fail-env-changed --timeout 600 -v ${{ env.PLATFORM_INDEPENDENT_TESTS }}
297325
timeout-minutes: 35
298326

299327
- if: runner.os == 'Linux'
300328
name: run cpython platform-dependent tests (Linux)
329+
env:
330+
RUSTPYTHON_SKIP_ENV_POLLUTERS: true
301331
run: target/release/rustpython -m test -j 1 -u all --slowest --fail-env-changed --timeout 600 -v -x ${{ env.PLATFORM_INDEPENDENT_TESTS }}
302332
timeout-minutes: 35
303333

304334
- if: runner.os == 'macOS'
305335
name: run cpython platform-dependent tests (MacOS)
336+
env:
337+
RUSTPYTHON_SKIP_ENV_POLLUTERS: true
306338
run: target/release/rustpython -m test -j 1 --slowest --fail-env-changed --timeout 600 -v -x ${{ env.PLATFORM_INDEPENDENT_TESTS }}
307339
timeout-minutes: 35
308340

309341
- if: runner.os == 'Windows'
310342
name: run cpython platform-dependent tests (windows partial - fixme)
343+
env:
344+
RUSTPYTHON_SKIP_ENV_POLLUTERS: true
311345
run:
312346
target/release/rustpython -m test -j 1 --slowest --fail-env-changed --timeout 600 -v -x ${{ env.PLATFORM_INDEPENDENT_TESTS }} ${{ env.WINDOWS_SKIPS }}
313347
timeout-minutes: 45
314348

349+
- if: runner.os == 'Linux'
350+
name: run cpython tests to check if env polluters have stopped polluting (Common/Linux)
351+
run: |
352+
for thing in ${{ env.ENV_POLLUTING_TESTS_COMMON }} ${{ env.ENV_POLLUTING_TESTS_LINUX }}; do
353+
! target/release/rustpython -m test -j 1 --slowest --fail-env-changed --timeout 600 -v ${thing}
354+
exitcode=$?
355+
if [ $exitcode -ne 0 ]; then
356+
echo "Test ${thing} is no longer polluting the environment!"
357+
exit 422
358+
fi
359+
done
360+
timeout-minutes: 15
361+
315362
- if: runner.os != 'Windows'
316363
name: check that --install-pip succeeds
317364
run: |

Lib/test/test_file_eintr.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,8 @@ def test_readall(self):
186186
class CTestFileIOSignalInterrupt(TestFileIOSignalInterrupt, unittest.TestCase):
187187
modname = '_io'
188188

189-
import json # TODO: RUSTPYTHON see below
190189
@unittest.skipIf(
191-
json.loads(next((x for x in sys.argv if "fail_env_changed" in x), '{"fail_env_changed":False}'))["fail_env_changed"],
190+
'RUSTPYTHON_SKIP_ENV_POLLUTERS' in os.environ,
192191
"TODO: RUSTPYTHON environment pollution when running rustpython -m test --fail-env-changed due to unknown reason"
193192
)
194193
# TODO: RUSTPYTHON - _io.FileIO.readall uses read_to_end which differs from _pyio.FileIO.readall

Lib/test/test_importlib/resources/test_resource.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ def test_is_file_failure_does_not_keep_open(self):
192192
def test_as_file_does_not_keep_open(self): # pragma: no cover
193193
resources.as_file(resources.files('ziptestdata') / 'binary.file')
194194

195-
import json # TODO: RUSTPYTHON see below
195+
import os # TODO: RUSTPYTHON see below
196196
@unittest.skipIf(
197-
json.loads(next((x for x in sys.argv if "fail_env_changed" in x), '{"fail_env_changed":False}'))["fail_env_changed"],
197+
'RUSTPYTHON_SKIP_ENV_POLLUTERS' in os.environ,
198198
"TODO: RUSTPYTHON environment pollution when running rustpython -m test --fail-env-changed due to tmpfile leak"
199199
)
200200
def test_entered_path_does_not_keep_open(self):

Lib/test/test_raise.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,9 @@ def f():
464464

465465
f()
466466

467-
import json # TODO: RUSTPYTHON see below
467+
import os # TODO: RUSTPYTHON see below
468468
@unittest.skipIf(
469-
json.loads(next((x for x in sys.argv if "fail_env_changed" in x), '{"fail_env_changed":False}'))["fail_env_changed"],
469+
'RUSTPYTHON_SKIP_ENV_POLLUTERS' in os.environ,
470470
"TODO: RUSTPYTHON environment pollution when running rustpython -m test --fail-env-changed due to unraisable exception"
471471
)
472472
def test_3611(self):

Lib/test/test_ssl.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4299,9 +4299,8 @@ def cb_returning_alert(ssl_sock, server_name, initial_context):
42994299
sni_name='supermessage')
43004300
self.assertEqual(cm.exception.reason, 'TLSV1_ALERT_ACCESS_DENIED')
43014301

4302-
import json # TODO: RUSTPYTHON see below
43034302
@unittest.skipIf(
4304-
json.loads(next((x for x in sys.argv if "fail_env_changed" in x), '{"fail_env_changed":False}'))["fail_env_changed"],
4303+
'RUSTPYTHON_SKIP_ENV_POLLUTERS' in os.environ,
43054304
"TODO: RUSTPYTHON environment pollution when running rustpython -m test --fail-env-changed due to unraisable exception"
43064305
)
43074306
@unittest.expectedFailure # TODO: RUSTPYTHON

Lib/test/test_subprocess.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,9 +1292,8 @@ def test_universal_newlines_communicate_stdin_stdout_stderr(self):
12921292
# to stderr at exit of subprocess.
12931293
self.assertTrue(stderr.startswith("eline2\neline6\neline7\n"))
12941294

1295-
import json # TODO: RUSTPYTHON see below
12961295
@unittest.skipIf(
1297-
json.loads(next((x for x in sys.argv if "fail_env_changed" in x), '{"fail_env_changed":False}'))["fail_env_changed"],
1296+
'RUSTPYTHON_SKIP_ENV_POLLUTERS' in os.environ,
12981297
"TODO: RUSTPYTHON environment pollution when running rustpython -m test --fail-env-changed due to unknown reason"
12991298
)
13001299
def test_universal_newlines_communicate_encodings(self):

Lib/test/test_sys.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,9 @@ def g456():
595595
leave_g.set()
596596
t.join()
597597

598-
import json # TODO: RUSTPYTHON see below
598+
import os # TODO: RUSTPYTHON see below
599599
@unittest.skipIf(
600-
json.loads(next((x for x in sys.argv if "fail_env_changed" in x), '{"fail_env_changed":False}'))["fail_env_changed"],
600+
'RUSTPYTHON_SKIP_ENV_POLLUTERS' in os.environ,
601601
"TODO: RUSTPYTHON environment pollution when running rustpython -m test --fail-env-changed due to dangling threads"
602602
)
603603
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError: module 'sys' has no attribute '_current_exceptions'

0 commit comments

Comments
 (0)