From 9d8f0316c1a93a197456691d1a807c8c96a01b79 Mon Sep 17 00:00:00 2001 From: Taylor Whatley <32211852+1whatleytay@users.noreply.github.com> Date: Sat, 13 Jan 2024 11:14:13 -0500 Subject: [PATCH 01/10] Add rust autotest target --- server/autotest_server/testers/__init__.py | 2 +- .../autotest_server/testers/rust/__init__.py | 0 .../testers/rust/requirements.system | 30 ++++ .../testers/rust/rust_tester.py | 166 ++++++++++++++++++ .../testers/rust/settings_schema.json | 57 ++++++ server/autotest_server/testers/rust/setup.py | 16 ++ 6 files changed, 270 insertions(+), 1 deletion(-) create mode 100644 server/autotest_server/testers/rust/__init__.py create mode 100755 server/autotest_server/testers/rust/requirements.system create mode 100644 server/autotest_server/testers/rust/rust_tester.py create mode 100644 server/autotest_server/testers/rust/settings_schema.json create mode 100644 server/autotest_server/testers/rust/setup.py diff --git a/server/autotest_server/testers/__init__.py b/server/autotest_server/testers/__init__.py index 1ca645c2..c0a8d91e 100644 --- a/server/autotest_server/testers/__init__.py +++ b/server/autotest_server/testers/__init__.py @@ -1,6 +1,6 @@ import os -_TESTERS = ("custom", "haskell", "java", "jupyter", "py", "pyta", "r", "racket") +_TESTERS = ("custom", "haskell", "java", "jupyter", "py", "pyta", "r", "racket", "rust") def install(testers=_TESTERS): diff --git a/server/autotest_server/testers/rust/__init__.py b/server/autotest_server/testers/rust/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/server/autotest_server/testers/rust/requirements.system b/server/autotest_server/testers/rust/requirements.system new file mode 100755 index 00000000..14e9b2e3 --- /dev/null +++ b/server/autotest_server/testers/rust/requirements.system @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +# The main repository for APT seems to be fairly old (1.65). +# Building cargo-nextest from source requires Rust 1.70, so I'm using rustup instead of a package manager. + +# We need a few things for our rust target. +# - curl for downloading rustup. Alternatively we can use wget. +# - rustup for installing rust and installing cargo-nextest. +# - cargo-nextest for machine readable test output. + +# Install Curl +if ! dpkg -l curl &> /dev/null; then + apt-get -y update + + DEBIAN_FRONTEND=noninteractive apt-get install -y -o 'Dpkg::Options::=--force-confdef' -o 'Dpkg::Options::=--force-confold' curl +fi + +# Install Rust +if ! command -v cargo &> /dev/null; then + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + + # Add cargo to the path. + . "$HOME/.cargo/env" +fi + +# Install Nextest +# For justification as to why we're using nextest, take a look at rust_tester.py. +if ! command -v cargo-nextest &> /dev/null; then + cargo install cargo-nextest --locked +fi diff --git a/server/autotest_server/testers/rust/rust_tester.py b/server/autotest_server/testers/rust/rust_tester.py new file mode 100644 index 00000000..f2cfe323 --- /dev/null +++ b/server/autotest_server/testers/rust/rust_tester.py @@ -0,0 +1,166 @@ +import os +import subprocess +from typing import Type +import json +from ..tester import Tester, Test, TestError +from ..specs import TestSpecs +from pathlib import Path +import re + +TEST_IDENTIFIER_REGEX = re.compile("^((?P.*)\\$)?(?P.*)$") + + +def parse_test_identifier(identifier: str) -> tuple[str, str]: + result = TEST_IDENTIFIER_REGEX.match(identifier) + + return result.group('exec'), result.group('test') + + +class RustTest(Test): + def __init__(self, tester: "RustTester", executable: str, test: str, success: bool, message: str) -> None: + self.executable = executable + self.test = test + self.success = success + self.message = message + + super().__init__(tester) + + @property + def test_name(self) -> str: + return self.test + + def run(self) -> str: + if self.success: + return self.passed(message=self.message) + else: + return self.failed(message=self.message) + + +def parse_adjacent_json(text: str) -> list[dict]: + skip = {'\n', '\r'} + + i = 0 + decoder = json.JSONDecoder() + + items = [] + + while i < len(text): + value, i = decoder.raw_decode(text, i) + + items.append(value) + + while i < len(text) and text[i] in skip: + i += 1 + + return items + + +class RustTester(Tester): + def __init__(self, specs: TestSpecs, test_class: Type[RustTest] = RustTest) -> None: + super().__init__(specs, test_class) + + def parse_test_events(self, items: list[dict]): + tests = [] + + for item in items: + # Ignore suite events. + if item["type"] != "test": + continue + + event = item["event"] + + finished_events = {"failed", "ok"} + + if event not in finished_events: + continue + + executable, test = parse_test_identifier(item["name"]) + + output = item["stdout"] if event == "failed" else "" + + tests.append(self.test_class( + self, + executable, + test, + event == "ok", + output + )) + + return tests + + # This should likely be moved to setup.py's create_environment. + def rust_env(self) -> dict: + # Hint to /bin/sh that it should look in $HOME/.cargo/bin. + # Despite .profile pointing to this directory, /bin/dash does not want to acknowledge it. + # There is conflicting information online as to whether-or-not .profile is respected by dash. + rust_home_path = os.path.join(Path.home(), '.cargo', 'bin') + + env = os.environ.copy() + + env["PATH"] = rust_home_path + ":" + env["PATH"] + + return env + + def compile_rust_tests(self, directory: str) -> subprocess.CompletedProcess: + command = [ + "cargo", + "nextest", + "run", + "--no-run", + "--color", + "never" + ] + + env = self.rust_env() + + return subprocess.run(command, cwd=directory, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + # We need a way to get machine-readable output from cargo test (why are we using nextest?). + # Here are the options I've explored: + # - cargo-test by default outputs human-readable strings. + # These strings might change in format over time, and I figure one tests stdout could bleed into another. + # - cargo-test supports machine-readable strings (via `cargo test -- --format json`). + # This option is nightly rust only, and enforcing nightly rust could cause other issues. + # - cargo-nextest supports experimental machine-readable output. + # While machine-readable output is experimental, it's based on yhr libtest standard that cargo test would use. + # nextest should also interact very similarly to `cargo test`. It should be very simple to swap to cargo-test. + # It's also reliable and only requires Rust 1.36 or earlier for running. + def run_rust_tests(self, directory: str) -> subprocess.CompletedProcess: + command = [ + "cargo", + "nextest", + "run", + "--no-fail-fast", + "--message-format", + "libtest-json", + "--color", + "never" + ] + + # Machine-readable output is experimental with Nextest. + env = self.rust_env() + env["NEXTEST_EXPERIMENTAL_LIBTEST_JSON"] = "1" + + return subprocess.run(command, cwd=directory, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + def run(self) -> None: + # Awkwardly, cargo doesn't have a great way of running files. + # Instead, it can run all the tests in a module (which is named after a file barring .rs and the path). + + try: + compile_result = self.compile_rust_tests(".") + + if compile_result.returncode != 0: + raise TestError(compile_result.stderr.decode("utf-8")) + except subprocess.CalledProcessError as e: + raise TestError(e) + + test_results = self.run_rust_tests(".") + + json_string = test_results.stdout.decode("utf-8") + test_events = parse_adjacent_json(json_string) + + tests = self.parse_test_events(test_events) + + for test in tests: + print(test.run(), flush=True) diff --git a/server/autotest_server/testers/rust/settings_schema.json b/server/autotest_server/testers/rust/settings_schema.json new file mode 100644 index 00000000..646ad997 --- /dev/null +++ b/server/autotest_server/testers/rust/settings_schema.json @@ -0,0 +1,57 @@ +{ + "type": "object", + "properties": { + "tester_type": { + "type": "string", + "enum": [ + "rust" + ] + }, + "test_data": { + "title": "Test Groups", + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "required": [ + "script_files", + "timeout" + ], + "properties": { + "script_files": { + "title": "Test files", + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/files_list" + }, + "uniqueItems": true + }, + "category": { + "title": "Category", + "type": "array", + "items": { + "$ref": "#/definitions/test_data_categories" + }, + "uniqueItems": true + }, + "timeout": { + "title": "Timeout", + "type": "integer", + "default": 30 + }, + "feedback_file_names": { + "title": "Feedback files", + "type": "array", + "items": { + "type": "string" + } + }, + "extra_info": { + "$ref": "#/definitions/extra_group_data" + } + } + } + } + } +} diff --git a/server/autotest_server/testers/rust/setup.py b/server/autotest_server/testers/rust/setup.py new file mode 100644 index 00000000..59081122 --- /dev/null +++ b/server/autotest_server/testers/rust/setup.py @@ -0,0 +1,16 @@ +import os +import json +import subprocess + + +def create_environment(settings_, env_dir, default_env_dir): + return {"PYTHON": os.path.join(default_env_dir, "bin", "python3")} + + +def settings(): + with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "settings_schema.json")) as f: + return json.load(f) + + +def install(): + subprocess.run(os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.system"), check=True) From 37a5220b42f36a6937cc944ba7730b07541ccd50 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 13 Jan 2024 16:26:25 +0000 Subject: [PATCH 02/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../testers/rust/rust_tester.py | 34 ++++--------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/server/autotest_server/testers/rust/rust_tester.py b/server/autotest_server/testers/rust/rust_tester.py index f2cfe323..133e3cae 100644 --- a/server/autotest_server/testers/rust/rust_tester.py +++ b/server/autotest_server/testers/rust/rust_tester.py @@ -13,7 +13,7 @@ def parse_test_identifier(identifier: str) -> tuple[str, str]: result = TEST_IDENTIFIER_REGEX.match(identifier) - return result.group('exec'), result.group('test') + return result.group("exec"), result.group("test") class RustTest(Test): @@ -37,7 +37,7 @@ def run(self) -> str: def parse_adjacent_json(text: str) -> list[dict]: - skip = {'\n', '\r'} + skip = {"\n", "\r"} i = 0 decoder = json.JSONDecoder() @@ -78,13 +78,7 @@ def parse_test_events(self, items: list[dict]): output = item["stdout"] if event == "failed" else "" - tests.append(self.test_class( - self, - executable, - test, - event == "ok", - output - )) + tests.append(self.test_class(self, executable, test, event == "ok", output)) return tests @@ -93,7 +87,7 @@ def rust_env(self) -> dict: # Hint to /bin/sh that it should look in $HOME/.cargo/bin. # Despite .profile pointing to this directory, /bin/dash does not want to acknowledge it. # There is conflicting information online as to whether-or-not .profile is respected by dash. - rust_home_path = os.path.join(Path.home(), '.cargo', 'bin') + rust_home_path = os.path.join(Path.home(), ".cargo", "bin") env = os.environ.copy() @@ -102,14 +96,7 @@ def rust_env(self) -> dict: return env def compile_rust_tests(self, directory: str) -> subprocess.CompletedProcess: - command = [ - "cargo", - "nextest", - "run", - "--no-run", - "--color", - "never" - ] + command = ["cargo", "nextest", "run", "--no-run", "--color", "never"] env = self.rust_env() @@ -126,16 +113,7 @@ def compile_rust_tests(self, directory: str) -> subprocess.CompletedProcess: # nextest should also interact very similarly to `cargo test`. It should be very simple to swap to cargo-test. # It's also reliable and only requires Rust 1.36 or earlier for running. def run_rust_tests(self, directory: str) -> subprocess.CompletedProcess: - command = [ - "cargo", - "nextest", - "run", - "--no-fail-fast", - "--message-format", - "libtest-json", - "--color", - "never" - ] + command = ["cargo", "nextest", "run", "--no-fail-fast", "--message-format", "libtest-json", "--color", "never"] # Machine-readable output is experimental with Nextest. env = self.rust_env() From f951f2d885ee9a43c6d87b8842ae889f2a68f31b Mon Sep 17 00:00:00 2001 From: Taylor Whatley <32211852+1whatleytay@users.noreply.github.com> Date: Sat, 13 Jan 2024 22:34:16 -0500 Subject: [PATCH 03/10] Add rust autotesting in README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 2486b0a7..69b162da 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,8 @@ The autotester currently supports testers for the following languages and testin - [RackUnit](https://docs.racket-lang.org/rackunit/) - `R` - [TestThat](https://testthat.r-lib.org/) +- `rust' + - [Cargo Test](https://doc.rust-lang.org/book/ch11-01-writing-tests.html) - `custom` - see more information [here](#the-custom-tester) @@ -160,6 +162,9 @@ Installing each tester will also install the following additional packages (syst - racket - `R` - R +- `Rust` + - Rust and Cargo (rustup) + - Cargo Nextest - `custom` - none From 275c7c7bbe4ac2da9f0298c7854fb5b0a09f8dad Mon Sep 17 00:00:00 2001 From: Taylor Whatley <32211852+1whatleytay@users.noreply.github.com> Date: Sun, 14 Jan 2024 18:46:59 -0500 Subject: [PATCH 04/10] Add test_modules property for rust autotesting --- .../testers/rust/rust_tester.py | 40 +++++++++++++++---- .../testers/rust/settings_schema.json | 13 +++--- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/server/autotest_server/testers/rust/rust_tester.py b/server/autotest_server/testers/rust/rust_tester.py index 133e3cae..7c883c32 100644 --- a/server/autotest_server/testers/rust/rust_tester.py +++ b/server/autotest_server/testers/rust/rust_tester.py @@ -1,6 +1,6 @@ import os import subprocess -from typing import Type +from typing import Type, Optional import json from ..tester import Tester, Test, TestError from ..specs import TestSpecs @@ -59,7 +59,7 @@ class RustTester(Tester): def __init__(self, specs: TestSpecs, test_class: Type[RustTest] = RustTest) -> None: super().__init__(specs, test_class) - def parse_test_events(self, items: list[dict]): + def parse_test_events(self, items: list[dict]) -> list[RustTest]: tests = [] for item in items: @@ -112,8 +112,20 @@ def compile_rust_tests(self, directory: str) -> subprocess.CompletedProcess: # While machine-readable output is experimental, it's based on yhr libtest standard that cargo test would use. # nextest should also interact very similarly to `cargo test`. It should be very simple to swap to cargo-test. # It's also reliable and only requires Rust 1.36 or earlier for running. - def run_rust_tests(self, directory: str) -> subprocess.CompletedProcess: - command = ["cargo", "nextest", "run", "--no-fail-fast", "--message-format", "libtest-json", "--color", "never"] + def run_rust_tests(self, directory: str, module: Optional[str]) -> subprocess.CompletedProcess: + command = [ + "cargo", + "nextest", + "run", + "--no-fail-fast", + "--message-format", + "libtest-json", + "--color", + "never" + ] + + if module is not None: + command.extend(["--lib", module]) # Machine-readable output is experimental with Nextest. env = self.rust_env() @@ -121,6 +133,14 @@ def run_rust_tests(self, directory: str) -> subprocess.CompletedProcess: return subprocess.run(command, cwd=directory, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + def run_and_parse_rust_tests(self, directory: str, module: Optional[str]) -> list[RustTest]: + test_results = self.run_rust_tests(directory, module) + + json_string = test_results.stdout.decode("utf-8") + test_events = parse_adjacent_json(json_string) + + return self.parse_test_events(test_events) + def run(self) -> None: # Awkwardly, cargo doesn't have a great way of running files. # Instead, it can run all the tests in a module (which is named after a file barring .rs and the path). @@ -133,12 +153,16 @@ def run(self) -> None: except subprocess.CalledProcessError as e: raise TestError(e) - test_results = self.run_rust_tests(".") + modules = self.specs["test_data", "test_modules"] + modules = [module for module in modules if module != ''] - json_string = test_results.stdout.decode("utf-8") - test_events = parse_adjacent_json(json_string) + tests = [] - tests = self.parse_test_events(test_events) + if len(modules) <= 0: + tests = self.run_and_parse_rust_tests(".", None) + else: + for module in modules: + tests.extend(self.run_and_parse_rust_tests(".", module)) for test in tests: print(test.run(), flush=True) diff --git a/server/autotest_server/testers/rust/settings_schema.json b/server/autotest_server/testers/rust/settings_schema.json index 646ad997..68ae4fff 100644 --- a/server/autotest_server/testers/rust/settings_schema.json +++ b/server/autotest_server/testers/rust/settings_schema.json @@ -14,18 +14,17 @@ "items": { "type": "object", "required": [ - "script_files", "timeout" ], "properties": { - "script_files": { - "title": "Test files", + "test_modules": { + "title": "Test Module Name", + "description": "Rust module names that contain tests to be run. An empty list will run all tests.", "type": "array", - "minItems": 1, "items": { - "$ref": "#/definitions/files_list" - }, - "uniqueItems": true + "type": "string", + "minLength": 1 + } }, "category": { "title": "Category", From 0fa08d08952c3289bdce68a41ff0a8fd03149743 Mon Sep 17 00:00:00 2001 From: Taylor Whatley <32211852+1whatleytay@users.noreply.github.com> Date: Sun, 14 Jan 2024 19:33:04 -0500 Subject: [PATCH 05/10] Switch autotest rust to single test_module --- .../autotest_server/testers/rust/rust_tester.py | 16 ++++++++-------- .../testers/rust/settings_schema.json | 12 ++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/server/autotest_server/testers/rust/rust_tester.py b/server/autotest_server/testers/rust/rust_tester.py index 7c883c32..9373e284 100644 --- a/server/autotest_server/testers/rust/rust_tester.py +++ b/server/autotest_server/testers/rust/rust_tester.py @@ -141,6 +141,7 @@ def run_and_parse_rust_tests(self, directory: str, module: Optional[str]) -> lis return self.parse_test_events(test_events) + @Tester.run_decorator def run(self) -> None: # Awkwardly, cargo doesn't have a great way of running files. # Instead, it can run all the tests in a module (which is named after a file barring .rs and the path). @@ -153,16 +154,15 @@ def run(self) -> None: except subprocess.CalledProcessError as e: raise TestError(e) - modules = self.specs["test_data", "test_modules"] - modules = [module for module in modules if module != ''] + module = self.specs.get("test_data", "test_module") - tests = [] + if module is not None: + module = module.strip() - if len(modules) <= 0: - tests = self.run_and_parse_rust_tests(".", None) - else: - for module in modules: - tests.extend(self.run_and_parse_rust_tests(".", module)) + if module == '': + module = None + + tests = self.run_and_parse_rust_tests(".", module) for test in tests: print(test.run(), flush=True) diff --git a/server/autotest_server/testers/rust/settings_schema.json b/server/autotest_server/testers/rust/settings_schema.json index 68ae4fff..d56d3830 100644 --- a/server/autotest_server/testers/rust/settings_schema.json +++ b/server/autotest_server/testers/rust/settings_schema.json @@ -17,14 +17,10 @@ "timeout" ], "properties": { - "test_modules": { - "title": "Test Module Name", - "description": "Rust module names that contain tests to be run. An empty list will run all tests.", - "type": "array", - "items": { - "type": "string", - "minLength": 1 - } + "test_module": { + "title": "Test module name", + "type": "string", + "minLength": 0 }, "category": { "title": "Category", From ff8a4512fc7116da488afc577a5f9015656cbbd4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 00:34:48 +0000 Subject: [PATCH 06/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- server/autotest_server/testers/rust/rust_tester.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/server/autotest_server/testers/rust/rust_tester.py b/server/autotest_server/testers/rust/rust_tester.py index 9373e284..b36ae0e3 100644 --- a/server/autotest_server/testers/rust/rust_tester.py +++ b/server/autotest_server/testers/rust/rust_tester.py @@ -113,16 +113,7 @@ def compile_rust_tests(self, directory: str) -> subprocess.CompletedProcess: # nextest should also interact very similarly to `cargo test`. It should be very simple to swap to cargo-test. # It's also reliable and only requires Rust 1.36 or earlier for running. def run_rust_tests(self, directory: str, module: Optional[str]) -> subprocess.CompletedProcess: - command = [ - "cargo", - "nextest", - "run", - "--no-fail-fast", - "--message-format", - "libtest-json", - "--color", - "never" - ] + command = ["cargo", "nextest", "run", "--no-fail-fast", "--message-format", "libtest-json", "--color", "never"] if module is not None: command.extend(["--lib", module]) @@ -159,7 +150,7 @@ def run(self) -> None: if module is not None: module = module.strip() - if module == '': + if module == "": module = None tests = self.run_and_parse_rust_tests(".", module) From 6d473fa02911bc102d6924ef9ce9eaa5013aa84b Mon Sep 17 00:00:00 2001 From: Taylor Whatley <32211852+1whatleytay@users.noreply.github.com> Date: Sun, 14 Jan 2024 20:44:31 -0500 Subject: [PATCH 07/10] Remove --lib option from rust autotester --- server/autotest_server/testers/rust/rust_tester.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/autotest_server/testers/rust/rust_tester.py b/server/autotest_server/testers/rust/rust_tester.py index b36ae0e3..612ccd77 100644 --- a/server/autotest_server/testers/rust/rust_tester.py +++ b/server/autotest_server/testers/rust/rust_tester.py @@ -115,8 +115,9 @@ def compile_rust_tests(self, directory: str) -> subprocess.CompletedProcess: def run_rust_tests(self, directory: str, module: Optional[str]) -> subprocess.CompletedProcess: command = ["cargo", "nextest", "run", "--no-fail-fast", "--message-format", "libtest-json", "--color", "never"] - if module is not None: - command.extend(["--lib", module]) + # Prevent CLI options from being propagated. + if module is not None or '-' in module: + command.append(module) # Machine-readable output is experimental with Nextest. env = self.rust_env() From 7f900729ecbb4e1c57443ac14243113360e3abf4 Mon Sep 17 00:00:00 2001 From: Taylor Whatley <32211852+1whatleytay@users.noreply.github.com> Date: Mon, 15 Jan 2024 13:27:34 -0500 Subject: [PATCH 08/10] Fix module string problem --- server/autotest_server/testers/rust/rust_tester.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/autotest_server/testers/rust/rust_tester.py b/server/autotest_server/testers/rust/rust_tester.py index 612ccd77..cb65dfa2 100644 --- a/server/autotest_server/testers/rust/rust_tester.py +++ b/server/autotest_server/testers/rust/rust_tester.py @@ -116,7 +116,7 @@ def run_rust_tests(self, directory: str, module: Optional[str]) -> subprocess.Co command = ["cargo", "nextest", "run", "--no-fail-fast", "--message-format", "libtest-json", "--color", "never"] # Prevent CLI options from being propagated. - if module is not None or '-' in module: + if module is not None and '-' in module: command.append(module) # Machine-readable output is experimental with Nextest. From 4730983360e97abd92957cea4ba4cf02f63066ef Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 18:28:12 +0000 Subject: [PATCH 09/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- server/autotest_server/testers/rust/rust_tester.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/autotest_server/testers/rust/rust_tester.py b/server/autotest_server/testers/rust/rust_tester.py index cb65dfa2..5132bf4e 100644 --- a/server/autotest_server/testers/rust/rust_tester.py +++ b/server/autotest_server/testers/rust/rust_tester.py @@ -116,7 +116,7 @@ def run_rust_tests(self, directory: str, module: Optional[str]) -> subprocess.Co command = ["cargo", "nextest", "run", "--no-fail-fast", "--message-format", "libtest-json", "--color", "never"] # Prevent CLI options from being propagated. - if module is not None and '-' in module: + if module is not None and "-" in module: command.append(module) # Machine-readable output is experimental with Nextest. From dab5da807d60b952d8a7fa91c1fbe749ef68d2f8 Mon Sep 17 00:00:00 2001 From: Taylor Whatley <32211852+1whatleytay@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:28:21 -0500 Subject: [PATCH 10/10] Prevent options from being passed to cargo test --- server/autotest_server/testers/rust/rust_tester.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/autotest_server/testers/rust/rust_tester.py b/server/autotest_server/testers/rust/rust_tester.py index 5132bf4e..d0ddf7c0 100644 --- a/server/autotest_server/testers/rust/rust_tester.py +++ b/server/autotest_server/testers/rust/rust_tester.py @@ -116,7 +116,7 @@ def run_rust_tests(self, directory: str, module: Optional[str]) -> subprocess.Co command = ["cargo", "nextest", "run", "--no-fail-fast", "--message-format", "libtest-json", "--color", "never"] # Prevent CLI options from being propagated. - if module is not None and "-" in module: + if module is not None and "-" not in module: command.append(module) # Machine-readable output is experimental with Nextest.