X Tutup
Skip to content

Commit fddd7cb

Browse files
authored
fix cron-ci (#7483)
* fix cron-ci * fix custom_text_test_runner
1 parent 4107217 commit fddd7cb

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

.github/workflows/cron-ci.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
name: Periodic checks/tasks
1313

1414
env:
15-
CARGO_ARGS: --no-default-features --features stdlib,importlib,encodings,ssl-rustls,jit
15+
CARGO_ARGS: --no-default-features --features stdlib,importlib,stdio,encodings,ssl-rustls,jit,host_env
1616
PYTHON_VERSION: "3.14.3"
1717

1818
jobs:
@@ -35,7 +35,7 @@ jobs:
3535
python-version: ${{ env.PYTHON_VERSION }}
3636
- run: sudo apt-get update && sudo apt-get -y install lcov
3737
- name: Run cargo-llvm-cov with Rust tests.
38-
run: cargo llvm-cov --no-report --workspace --exclude rustpython_wasm --exclude rustpython-compiler-source --exclude rustpython-venvlauncher --verbose --no-default-features --features stdlib,importlib,encodings,ssl-rustls,jit
38+
run: cargo llvm-cov --no-report --workspace --exclude rustpython_wasm --exclude rustpython-compiler-source --exclude rustpython-venvlauncher --verbose --no-default-features --features stdlib,importlib,stdio,encodings,ssl-rustls,jit,host_env
3939
- name: Run cargo-llvm-cov with Python snippets.
4040
run: python scripts/cargo-llvm-cov.py
4141
continue-on-error: true
@@ -48,7 +48,7 @@ jobs:
4848
if: ${{ github.event_name != 'pull_request' }}
4949
uses: codecov/codecov-action@v5
5050
with:
51-
file: ./codecov.lcov
51+
files: ./codecov.lcov
5252

5353
testdata:
5454
name: Collect regression test data
@@ -170,12 +170,12 @@ jobs:
170170
- name: restructure generated files
171171
run: |
172172
cd ./target/criterion/reports
173-
find -type d -name cpython | xargs rm -rf
174-
find -type d -name rustpython | xargs rm -rf
175-
find -mindepth 2 -maxdepth 2 -name violin.svg | xargs rm -rf
176-
find -type f -not -name violin.svg | xargs rm -rf
177-
for file in $(find -type f -name violin.svg); do mv $file $(echo $file | sed -E "s_\./([^/]+)/([^/]+)/violin\.svg_./\1/\2.svg_"); done
178-
find -mindepth 2 -maxdepth 2 -type d | xargs rm -rf
173+
find . -type d -name cpython -print0 | xargs -0 rm -rf
174+
find . -type d -name rustpython -print0 | xargs -0 rm -rf
175+
find . -mindepth 2 -maxdepth 2 -name violin.svg -print0 | xargs -0 rm -rf
176+
find . -type f -not -name violin.svg -print0 | xargs -0 rm -rf
177+
find . -type f -name violin.svg -exec sh -c 'for file; do mv "$file" "$(echo "$file" | sed -E "s_\./([^/]+)/([^/]+)/violin\.svg_./\1/\2.svg_")"; done' _ {} +
178+
find . -mindepth 2 -maxdepth 2 -type d -print0 | xargs -0 rm -rf
179179
cd ..
180180
mv reports/* .
181181
rmdir reports

extra_tests/custom_text_test_runner.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@
3838
from unittest.runner import registerResult, result
3939

4040

41+
def _get_method_dict(test):
42+
"""Get the __dict__ of the underlying function for a test method.
43+
44+
Works for both bound methods (__func__.__dict__) and plain functions.
45+
"""
46+
method = getattr(test, test._testMethodName)
47+
func = getattr(method, "__func__", method)
48+
return func.__dict__
49+
50+
4151
class TablePrinter(object):
4252
# Modified from https://github.com/agramian/table-printer, same license as above
4353
"Print a list of dicts as a table"
@@ -325,9 +335,7 @@ def startTest(self, test):
325335
self.stream.writeln("TEST SUITE: %s" % self.suite)
326336
self.stream.writeln("Description: %s" % self.getSuiteDescription(test))
327337
try:
328-
name_override = getattr(test, test._testMethodName).__func__.__dict__[
329-
"test_case_name"
330-
]
338+
name_override = _get_method_dict(test)["test_case_name"]
331339
except:
332340
name_override = None
333341
self.case = name_override if name_override else self.case
@@ -345,7 +353,11 @@ def startTest(self, test):
345353
self.results["suites"][self.suite_number] = {
346354
"name": self.suite,
347355
"class": test.__class__.__name__,
348-
"module": re.compile(".* \((.*)\)").match(str(test)).group(1),
356+
"module": (
357+
m.group(1)
358+
if (m := re.compile(r".* \((.*)\)").match(str(test)))
359+
else str(test)
360+
),
349361
"description": self.getSuiteDescription(test),
350362
"cases": {},
351363
"used_case_names": {},
@@ -380,34 +392,22 @@ def startTest(self, test):
380392
if "test_type" in getattr(
381393
test, test._testMethodName
382394
).__func__.__dict__ and set([s.lower() for s in self.test_types]) == set(
383-
[
384-
s.lower()
385-
for s in getattr(test, test._testMethodName).__func__.__dict__[
386-
"test_type"
387-
]
388-
]
395+
[s.lower() for s in _get_method_dict(test)["test_type"]]
389396
):
390397
pass
391398
else:
392-
getattr(test, test._testMethodName).__func__.__dict__[
393-
"__unittest_skip_why__"
394-
] = 'Test run specified to only run tests of type "%s"' % ",".join(
395-
self.test_types
399+
_get_method_dict(test)["__unittest_skip_why__"] = (
400+
'Test run specified to only run tests of type "%s"'
401+
% ",".join(self.test_types)
396402
)
397-
getattr(test, test._testMethodName).__func__.__dict__[
398-
"__unittest_skip__"
399-
] = True
400-
if "skip_device" in getattr(test, test._testMethodName).__func__.__dict__:
401-
for device in getattr(test, test._testMethodName).__func__.__dict__[
402-
"skip_device"
403-
]:
403+
_get_method_dict(test)["__unittest_skip__"] = True
404+
if "skip_device" in _get_method_dict(test):
405+
for device in _get_method_dict(test)["skip_device"]:
404406
if self.config and device.lower() in self.config["device_name"].lower():
405-
getattr(test, test._testMethodName).__func__.__dict__[
406-
"__unittest_skip_why__"
407-
] = "Test is marked to be skipped on %s" % device
408-
getattr(test, test._testMethodName).__func__.__dict__[
409-
"__unittest_skip__"
410-
] = True
407+
_get_method_dict(test)["__unittest_skip_why__"] = (
408+
"Test is marked to be skipped on %s" % device
409+
)
410+
_get_method_dict(test)["__unittest_skip__"] = True
411411
break
412412

413413
def stopTest(self, test):

0 commit comments

Comments
 (0)
X Tutup