259 lines
11 KiB
Diff
259 lines
11 KiB
Diff
From 4d9ee66b36192b8ba489110f781e44428f0c9afd Mon Sep 17 00:00:00 2001
|
|
From: Naveen M K <naveen521kk@gmail.com>
|
|
Date: Tue, 20 Feb 2024 11:04:39 +0530
|
|
Subject: [PATCH 116/N] CI: clean up ignored tests
|
|
|
|
Remove tests which are passing now, or no longer exist, and
|
|
move tests which only fail with msvcrt into a separate file.
|
|
---
|
|
.github/workflows/mingw.yml | 12 ++-
|
|
Lib/test/test_wmi.py | 148 ++++++++++++++++++------------------
|
|
mingw_ignorefile.txt | 23 +-----
|
|
mingw_ignorefile_msvcrt.txt | 8 ++
|
|
4 files changed, 94 insertions(+), 97 deletions(-)
|
|
create mode 100644 mingw_ignorefile_msvcrt.txt
|
|
|
|
diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml
|
|
index f0a0d92..c3001cd 100644
|
|
--- a/.github/workflows/mingw.yml
|
|
+++ b/.github/workflows/mingw.yml
|
|
@@ -91,16 +91,24 @@ jobs:
|
|
shell: msys2 {0}
|
|
run: |
|
|
IGNOREFILE="$(pwd)/mingw_ignorefile.txt"
|
|
+ IGNOREFILE_EXTRA="$IGNOREFILE"
|
|
+ if [[ "${{ matrix.msystem }}" == "MINGW32" ]] || [[ "${{ matrix.msystem }}" == "MINGW64" ]]; then
|
|
+ IGNOREFILE_EXTRA="$(pwd)/mingw_ignorefile_msvcrt.txt"
|
|
+ fi
|
|
cd _build
|
|
- MSYSTEM= ./python.exe -m test -j8 --ignorefile "$IGNOREFILE" -W
|
|
+ MSYSTEM= ./python.exe -m test -j8 --ignorefile "$IGNOREFILE" --ignorefile "$IGNOREFILE_EXTRA" -W
|
|
|
|
- name: Run broken tests
|
|
continue-on-error: true
|
|
shell: msys2 {0}
|
|
run: |
|
|
IGNOREFILE="$(pwd)/mingw_ignorefile.txt"
|
|
+ IGNOREFILE_EXTRA="$IGNOREFILE"
|
|
+ if [[ "${{ matrix.msystem }}" == "MINGW32" ]] || [[ "${{ matrix.msystem }}" == "MINGW64" ]]; then
|
|
+ IGNOREFILE_EXTRA="$(pwd)/mingw_ignorefile_msvcrt.txt"
|
|
+ fi
|
|
cd _build
|
|
- MSYSTEM= ./python.exe -m test -j8 --matchfile "$IGNOREFILE" -W
|
|
+ MSYSTEM= ./python.exe -m test -j8 --matchfile "$IGNOREFILE" --matchfile "$IGNOREFILE_EXTRA" -W
|
|
|
|
- name: Install
|
|
shell: msys2 {0}
|
|
diff --git a/Lib/test/test_wmi.py b/Lib/test/test_wmi.py
|
|
index 3445702..542dbc1 100644
|
|
--- a/Lib/test/test_wmi.py
|
|
+++ b/Lib/test/test_wmi.py
|
|
@@ -1,74 +1,74 @@
|
|
-# Test the internal _wmi module on Windows
|
|
-# This is used by the platform module, and potentially others
|
|
-
|
|
-import unittest
|
|
-from test.support import import_helper, requires_resource
|
|
-
|
|
-
|
|
-# Do this first so test will be skipped if module doesn't exist
|
|
-_wmi = import_helper.import_module('_wmi', required_on=['win'])
|
|
-
|
|
-
|
|
-class WmiTests(unittest.TestCase):
|
|
- def test_wmi_query_os_version(self):
|
|
- r = _wmi.exec_query("SELECT Version FROM Win32_OperatingSystem").split("\0")
|
|
- self.assertEqual(1, len(r))
|
|
- k, eq, v = r[0].partition("=")
|
|
- self.assertEqual("=", eq, r[0])
|
|
- self.assertEqual("Version", k, r[0])
|
|
- # Best we can check for the version is that it's digits, dot, digits, anything
|
|
- # Otherwise, we are likely checking the result of the query against itself
|
|
- self.assertRegex(v, r"\d+\.\d+.+$", r[0])
|
|
-
|
|
- def test_wmi_query_repeated(self):
|
|
- # Repeated queries should not break
|
|
- for _ in range(10):
|
|
- self.test_wmi_query_os_version()
|
|
-
|
|
- def test_wmi_query_error(self):
|
|
- # Invalid queries fail with OSError
|
|
- try:
|
|
- _wmi.exec_query("SELECT InvalidColumnName FROM InvalidTableName")
|
|
- except OSError as ex:
|
|
- if ex.winerror & 0xFFFFFFFF == 0x80041010:
|
|
- # This is the expected error code. All others should fail the test
|
|
- return
|
|
- self.fail("Expected OSError")
|
|
-
|
|
- def test_wmi_query_repeated_error(self):
|
|
- for _ in range(10):
|
|
- self.test_wmi_query_error()
|
|
-
|
|
- def test_wmi_query_not_select(self):
|
|
- # Queries other than SELECT are blocked to avoid potential exploits
|
|
- with self.assertRaises(ValueError):
|
|
- _wmi.exec_query("not select, just in case someone tries something")
|
|
-
|
|
- @requires_resource('cpu')
|
|
- def test_wmi_query_overflow(self):
|
|
- # Ensure very big queries fail
|
|
- # Test multiple times to ensure consistency
|
|
- for _ in range(2):
|
|
- with self.assertRaises(OSError):
|
|
- _wmi.exec_query("SELECT * FROM CIM_DataFile")
|
|
-
|
|
- def test_wmi_query_multiple_rows(self):
|
|
- # Multiple instances should have an extra null separator
|
|
- r = _wmi.exec_query("SELECT ProcessId FROM Win32_Process WHERE ProcessId < 1000")
|
|
- self.assertFalse(r.startswith("\0"), r)
|
|
- self.assertFalse(r.endswith("\0"), r)
|
|
- it = iter(r.split("\0"))
|
|
- try:
|
|
- while True:
|
|
- self.assertRegex(next(it), r"ProcessId=\d+")
|
|
- self.assertEqual("", next(it))
|
|
- except StopIteration:
|
|
- pass
|
|
-
|
|
- def test_wmi_query_threads(self):
|
|
- from concurrent.futures import ThreadPoolExecutor
|
|
- query = "SELECT ProcessId FROM Win32_Process WHERE ProcessId < 1000"
|
|
- with ThreadPoolExecutor(4) as pool:
|
|
- task = [pool.submit(_wmi.exec_query, query) for _ in range(32)]
|
|
- for t in task:
|
|
- self.assertRegex(t.result(), "ProcessId=")
|
|
+# Test the internal _wmi module on Windows
|
|
+# This is used by the platform module, and potentially others
|
|
+
|
|
+import unittest
|
|
+from test.support import import_helper, requires_resource
|
|
+
|
|
+
|
|
+# Do this first so test will be skipped if module doesn't exist
|
|
+_wmi = import_helper.import_module('_wmi')
|
|
+
|
|
+
|
|
+class WmiTests(unittest.TestCase):
|
|
+ def test_wmi_query_os_version(self):
|
|
+ r = _wmi.exec_query("SELECT Version FROM Win32_OperatingSystem").split("\0")
|
|
+ self.assertEqual(1, len(r))
|
|
+ k, eq, v = r[0].partition("=")
|
|
+ self.assertEqual("=", eq, r[0])
|
|
+ self.assertEqual("Version", k, r[0])
|
|
+ # Best we can check for the version is that it's digits, dot, digits, anything
|
|
+ # Otherwise, we are likely checking the result of the query against itself
|
|
+ self.assertRegex(v, r"\d+\.\d+.+$", r[0])
|
|
+
|
|
+ def test_wmi_query_repeated(self):
|
|
+ # Repeated queries should not break
|
|
+ for _ in range(10):
|
|
+ self.test_wmi_query_os_version()
|
|
+
|
|
+ def test_wmi_query_error(self):
|
|
+ # Invalid queries fail with OSError
|
|
+ try:
|
|
+ _wmi.exec_query("SELECT InvalidColumnName FROM InvalidTableName")
|
|
+ except OSError as ex:
|
|
+ if ex.winerror & 0xFFFFFFFF == 0x80041010:
|
|
+ # This is the expected error code. All others should fail the test
|
|
+ return
|
|
+ self.fail("Expected OSError")
|
|
+
|
|
+ def test_wmi_query_repeated_error(self):
|
|
+ for _ in range(10):
|
|
+ self.test_wmi_query_error()
|
|
+
|
|
+ def test_wmi_query_not_select(self):
|
|
+ # Queries other than SELECT are blocked to avoid potential exploits
|
|
+ with self.assertRaises(ValueError):
|
|
+ _wmi.exec_query("not select, just in case someone tries something")
|
|
+
|
|
+ @requires_resource('cpu')
|
|
+ def test_wmi_query_overflow(self):
|
|
+ # Ensure very big queries fail
|
|
+ # Test multiple times to ensure consistency
|
|
+ for _ in range(2):
|
|
+ with self.assertRaises(OSError):
|
|
+ _wmi.exec_query("SELECT * FROM CIM_DataFile")
|
|
+
|
|
+ def test_wmi_query_multiple_rows(self):
|
|
+ # Multiple instances should have an extra null separator
|
|
+ r = _wmi.exec_query("SELECT ProcessId FROM Win32_Process WHERE ProcessId < 1000")
|
|
+ self.assertFalse(r.startswith("\0"), r)
|
|
+ self.assertFalse(r.endswith("\0"), r)
|
|
+ it = iter(r.split("\0"))
|
|
+ try:
|
|
+ while True:
|
|
+ self.assertRegex(next(it), r"ProcessId=\d+")
|
|
+ self.assertEqual("", next(it))
|
|
+ except StopIteration:
|
|
+ pass
|
|
+
|
|
+ def test_wmi_query_threads(self):
|
|
+ from concurrent.futures import ThreadPoolExecutor
|
|
+ query = "SELECT ProcessId FROM Win32_Process WHERE ProcessId < 1000"
|
|
+ with ThreadPoolExecutor(4) as pool:
|
|
+ task = [pool.submit(_wmi.exec_query, query) for _ in range(32)]
|
|
+ for t in task:
|
|
+ self.assertRegex(t.result(), "ProcessId=")
|
|
diff --git a/mingw_ignorefile.txt b/mingw_ignorefile.txt
|
|
index e692d7f..ec94c35 100644
|
|
--- a/mingw_ignorefile.txt
|
|
+++ b/mingw_ignorefile.txt
|
|
@@ -2,16 +2,11 @@ test.test_ctypes.test_loading.LoaderTest.test_load_dll_with_flags
|
|
distutils.tests.test_bdist_dumb.BuildDumbTestCase.test_simple_built
|
|
distutils.tests.test_cygwinccompiler.CygwinCCompilerTestCase.test_get_versions
|
|
distutils.tests.test_util.UtilTestCase.test_change_root
|
|
-test.datetimetester.TestLocalTimeDisambiguation_Fast.*
|
|
-test.datetimetester.TestLocalTimeDisambiguation_Pure.*
|
|
-test.test_cmath.CMathTests.test_specific_values
|
|
-test.test_cmd_line_script.CmdLineTest.test_consistent_sys_path_for_direct_execution
|
|
test.test_compileall.CommandLineTestsNoSourceEpoch.*
|
|
test.test_compileall.CommandLineTestsWithSourceEpoch.*
|
|
test.test_compileall.CompileallTestsWithoutSourceEpoch.*
|
|
test.test_compileall.CompileallTestsWithSourceEpoch.*
|
|
test.test_import.ImportTests.test_dll_dependency_import
|
|
-test.test_math.MathTests.*
|
|
test.test_ntpath.NtCommonTest.test_import
|
|
test.test_os.StatAttributeTests.test_stat_block_device
|
|
test.test_os.TestScandir.test_attributes
|
|
@@ -23,21 +18,7 @@ test.test_site._pthFileTests.*
|
|
test.test_site.HelperFunctionsTests.*
|
|
test.test_site.StartupImportTests.*
|
|
test.test_ssl.*
|
|
-test.test_strptime.CalculationTests.*
|
|
-test.test_strptime.StrptimeTests.test_weekday
|
|
-test.test_strptime.TimeRETests.test_compile
|
|
-test.test_tools.test_i18n.Test_pygettext.test_POT_Creation_Date
|
|
test.test_venv.BasicTest.*
|
|
test.test_venv.EnsurePipTest.*
|
|
-test.test_sysconfig.TestSysConfig.test_user_similar
|
|
-test.test_tcl.TclTest.testLoadWithUNC
|
|
-test.test_wmi
|
|
-# flaky
|
|
-test.test__xxsubinterpreters.*
|
|
-test.test_asyncio.test_subprocess.SubprocessProactorTests.test_stdin_broken_pipe
|
|
-test.test_asynchat.TestAsynchat.test_line_terminator2
|
|
-test.test_asyncgen.AsyncGenAsyncioTest.test_async_gen_asyncio_gc_aclose_09
|
|
-test.test_concurrent_futures.ThreadPoolShutdownTest.test_interpreter_shutdown
|
|
-test.test_asynchat.TestNotConnected.test_disallow_negative_terminator
|
|
-test.test_logging.SysLogHandlerTest.*
|
|
-test.test_logging.IPv6SysLogHandlerTest.*
|
|
+
|
|
+test.test_dict.DictTest.test_splittable_to_generic_combinedtable
|
|
diff --git a/mingw_ignorefile_msvcrt.txt b/mingw_ignorefile_msvcrt.txt
|
|
new file mode 100644
|
|
index 0000000..be363bd
|
|
--- /dev/null
|
|
+++ b/mingw_ignorefile_msvcrt.txt
|
|
@@ -0,0 +1,8 @@
|
|
+test.datetimetester.TestLocalTimeDisambiguation_Fast.*
|
|
+test.datetimetester.TestLocalTimeDisambiguation_Pure.*
|
|
+test.test_cmath.CMathTests.test_specific_values
|
|
+test.test_math.MathTests.*
|
|
+test.test_strptime.CalculationTests.*
|
|
+test.test_strptime.StrptimeTests.test_weekday
|
|
+test.test_strptime.TimeRETests.test_compile
|
|
+test.test_tools.test_i18n.Test_pygettext.test_POT_Creation_Date
|