Skip to content

Commit 1fd81f9

Browse files
committed
Add --fast-ci and --slow-ci as options of test and ci subcommands
1 parent b680f0e commit 1fd81f9

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ jobs:
421421
with:
422422
persist-credentials: false
423423
- name: Build and test
424-
run: ./Android/android.py ci ${{ matrix.arch }}-linux-android
424+
run: ./Android/android.py ci --fast-ci ${{ matrix.arch }}-linux-android
425425

426426
build-wasi:
427427
name: 'WASI'

Android/android.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,17 @@ async def gradle_task(context):
547547
task_prefix = "connected"
548548
env["ANDROID_SERIAL"] = context.connected
549549

550+
if context.ci_mode:
551+
context.args[0:0] = [
552+
# See _add_ci_python_opts in libregrtest/main.py.
553+
"-W", "error", "-bb", "-E",
554+
555+
# Randomization is disabled because order-dependent failures are
556+
# much less likely to pass on a rerun in single-process mode.
557+
"-m", "test",
558+
f"--{context.ci_mode}-ci", "--single-process", "--no-randomize"
559+
]
560+
550561
if not any(arg in context.args for arg in ["-c", "-m"]):
551562
context.args[0:0] = ["-m", "test"]
552563

@@ -733,18 +744,11 @@ def ci(context):
733744

734745
# Prove the package is self-contained by using it to run the tests.
735746
shutil.unpack_archive(package_path, temp_dir)
736-
737-
launcher_args = ["--managed", "maxVersion", "-v"]
738-
test_args = [
739-
# See _add_ci_python_opts in libregrtest/main.py.
740-
"-W", "error", "-bb", "-E",
741-
742-
# Randomization is disabled because order-dependent failures are
743-
# much less likely to pass on a rerun in single-process mode.
744-
"-m", "test", "--fast-ci", "--single-process", "--no-randomize"
747+
launcher_args = [
748+
"--managed", "maxVersion", "-v", f"--{context.ci_mode}-ci"
745749
]
746750
run(
747-
["./android.py", "test", *launcher_args, "--", *test_args],
751+
["./android.py", "test", *launcher_args],
748752
cwd=temp_dir
749753
)
750754
print("::endgroup::")
@@ -839,6 +843,16 @@ def add_parser(*args, **kwargs):
839843
"-g", action="store_true", default=False, dest="debug",
840844
help="Include debug information in package")
841845

846+
# CI arguments
847+
for subcommand in [test, ci]:
848+
group = subcommand.add_mutually_exclusive_group(required=subcommand is ci)
849+
group.add_argument(
850+
"--fast-ci", action="store_const", dest="ci_mode", const="fast",
851+
help="Add test arguments for GitHub Actions")
852+
group.add_argument(
853+
"--slow-ci", action="store_const", dest="ci_mode", const="slow",
854+
help="Add test arguments for buildbots")
855+
842856
return parser.parse_args()
843857

844858

Lib/test/libregrtest/main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -648,10 +648,9 @@ def _add_cross_compile_opts(self, regrtest_opts):
648648
def _add_ci_python_opts(self, python_opts, keep_environ):
649649
# --fast-ci and --slow-ci add options to Python.
650650
#
651-
# Some platforms cannot change options after startup, so if these
652-
# options are changed, also update the copies in:
653-
# * cpython/Android/android.py
654-
# * buildmaster-config/master/custom/factories.py
651+
# Some platforms run tests in embedded mode and cannot change options
652+
# after startup, so if this function changes, consider also updating:
653+
# * gradle_task in Android/android.py
655654

656655
# Unbuffered stdout and stderr. This isn't helpful on Android, because
657656
# it would cause lines to be split into multiple log messages.
@@ -678,7 +677,8 @@ def _execute_python(self, cmd, environ):
678677

679678
cmd_text = shlex.join(cmd)
680679
try:
681-
# Android and iOS run tests in embedded mode.
680+
# Android and iOS run tests in embedded mode. To update their
681+
# Python options, see the comment in _add_ci_python_opts.
682682
if not cmd[0]:
683683
raise ValueError("No Python executable is present")
684684

0 commit comments

Comments
 (0)