Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep test-only precompilation scoped to changed Go packages

pulse-triage[bot]76c847703553
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
index 59ae3b398b..15e0a69096 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -426,7 +426,8 @@ jobs:
# Reject cross-package test/API incompatibilities before spending seven
# runners on race tests. This links test binaries but never executes them;
- # the existing required checks below still own runtime and vet verdicts.
+ # an exclusively test-file diff compiles its packages and imports, otherwise
+ # all packages compile. Required checks below still own runtime/vet verdicts.
test-compile:
name: Compile backend race tests (no execution)
needs: changes
@@ -438,6 +439,10 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
+ # Include a PR merge's base or a single-push parent. An older or
+ # unavailable base safely retains full compilation; never fetch it
+ # through another command inside the source selector.
+ fetch-depth: 2
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
@@ -448,7 +453,10 @@ jobs:
- name: Provide frontend test embed stub
run: bash scripts/ensure_test_assets.sh
- - name: Compile every Go race-test binary without executing it
+ - name: Compile affected Go race-test binaries without executing them
+ env:
+ PULSE_GO_COMPILE_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
+ PULSE_GO_COMPILE_HEAD: ${{ github.sha }}
run: bash scripts/compile-go-tests.sh
backend:
diff --git a/scripts/compile-go-tests.sh b/scripts/compile-go-tests.sh
index efc363f1e5..e411fb77ef 100644
--- a/scripts/compile-go-tests.sh
+++ b/scripts/compile-go-tests.sh
@@ -3,10 +3,32 @@
# initialisers, TestMain, tests or examples. This is not a test verdict.
set -euo pipefail
-echo 'Compiling all Go race-test binaries; no test binary will execute.'
+ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+selection="$(python3 "$ROOT_DIR/scripts/select-go-test-compile-packages.py" \
+ --base "${PULSE_GO_COMPILE_BASE:-}" --head "${PULSE_GO_COMPILE_HEAD:-}")"
+# An unavailable Git diff selects ./...; a broken selector must not turn the
+# gate into a successful no-op. Paths are literal package arguments, not flags.
+if [[ -z "$selection" ]]; then
+ echo 'Go precompilation returned no package selection.' >&2
+ exit 1
+fi
+mapfile -t packages <<< "$selection"
+for package in "${packages[@]}"; do
+ if [[ "$package" != . && "$package" != ./... && ! "$package" =~ ^\./[A-Za-z0-9][A-Za-z0-9_.-]*(/[A-Za-z0-9][A-Za-z0-9_.-]*)*$ ]]; then
+ echo 'Go precompilation returned an invalid package selection.' >&2
+ exit 1
+ fi
+done
# -exec replaces execution of each successfully linked binary. In contrast,
# -run '^$' alone still runs init and TestMain. Vet and real test execution
# remain in the existing required backend shards. Disable result caching so
# the output cannot be mistaken for a previously executed test result.
-go test -race -vet=off -count=1 -exec /bin/true ./...
-echo 'All Go race-test binaries compiled; runtime tests remain required.'
+if [[ "$selection" == ./... ]]; then
+ echo 'Compiling all Go race-test binaries; no test binary will execute.'
+ go test -race -vet=off -count=1 -exec /bin/true ./...
+else
+ printf 'Compiling %s changed-test package(s) and their imports; no test binary will execute.\n' "${#packages[@]}"
+ printf ' %s\n' "${packages[@]}"
+ go test -race -vet=off -count=1 -exec /bin/true "${packages[@]}"
+fi
+echo 'Selected Go race-test binaries compiled; runtime tests remain required.'
diff --git a/scripts/go-test-compile-required.sh b/scripts/go-test-compile-required.sh
index 5b597f208b..8e1d7c9b77 100644
--- a/scripts/go-test-compile-required.sh
+++ b/scripts/go-test-compile-required.sh
@@ -4,7 +4,7 @@
# cannot invalidate its test API. An unavailable diff is handled as true by CI.
set -euo pipefail
-if grep -E '^go\.(mod|sum)$|^(internal|cmd|pkg)/|^scripts/(compile-go-tests|go-test-compile-required|ensure_test_assets)\.sh$|^\.github/workflows/build-and-test\.yml$|\.(go|c|cc|cpp|h|s|S|syso)$' >/dev/null; then
+if grep -E '^go\.(mod|sum)$|^(internal|cmd|pkg)/|^scripts/(compile-go-tests|go-test-compile-required|ensure_test_assets)\.sh$|^scripts/select-go-test-compile-packages\.py$|^\.github/workflows/build-and-test\.yml$|\.(go|c|cc|cpp|h|s|S|syso)$' >/dev/null; then
printf 'true\n'
else
printf 'false\n'
diff --git a/scripts/select-go-test-compile-packages.py b/scripts/select-go-test-compile-packages.py
new file mode 100644
index 0000000000..b02ef5f471
--- /dev/null
+++ b/scripts/select-go-test-compile-packages.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python3
+"""Narrow inert precompilation only for an exact, exclusively test-file diff.
+
+Keep early rejection of broken fixtures before backend fan-out. Test files
+cannot be imported by another package, so compile their packages and imports
+instead of every unrelated test binary. All runtime/vet checks remain required.
+Any incomplete or ambiguous source evidence retains the full compilation.
+"""
+
+import argparse
+from pathlib import Path, PurePosixPath
+import re
+import subprocess
+import sys
+
+
+COMMIT = re.compile(r"[0-9a-f]{40}")
+HEADER = re.compile(rb":(000000|100644) 100644 ([0-9a-f]{40}) ([0-9a-f]{40}) ([AM])")
+TEST_PATH = re.compile(rb"(?:[A-Za-z0-9][A-Za-z0-9_.-]*/)*[A-Za-z0-9][A-Za-z0-9_]*_test\.go")
+FULL = ["./..."]
+
+
+def changed_test_packages(raw, tree):
+ if not raw or not raw.endswith(b"\0") or not tree.endswith(b"\0"):
+ return FULL
+ records = raw[:-1].split(b"\0")
+ files = tree[:-1].split(b"\0")
+ if (len(records) % 2 or len(files) != len(set(files))
+ or b"go.mod" not in files or b"go.work" in files):
+ return FULL
+ files = set(files)
+ seen = set()
+ packages = set()
+ for header, path in zip(records[::2], records[1::2]):
+ match = HEADER.fullmatch(header)
+ if not match or not TEST_PATH.fullmatch(path) or path in seen or path not in files:
+ return FULL
+ old_mode, old_blob, new_blob, status = match.groups()
+ if (new_blob == b"0" * 40 or (status == b"A" and (old_mode != b"000000" or old_blob != b"0" * 40))
+ or (status == b"M" and (old_mode != b"100644" or old_blob == b"0" * 40))):
+ return FULL
+ seen.add(path)
+ parent = PurePosixPath(path.decode("ascii")).parent
+ if any(part in ("vendor", "testdata") for part in parent.parts):
+ return FULL
+ # A nested module is not part of the root ./... contract. Do not infer
+ # a new compiler/module invocation from a similarly named test file.
+ if any(str(ancestor / "go.mod").encode() in files
+ for ancestor in (parent, *parent.parents) if str(ancestor) != "."):
+ return FULL
+ packages.add("./" + str(parent) if str(parent) != "." else ".")
+ return sorted(packages) or FULL
+
+
+def read_git(*args):
+ return subprocess.run(["git", *args], capture_output=True, timeout=30, check=True).stdout
+
+
+def root_package_directories():
+ result = subprocess.run(["go", "list", "-f", "{{.Dir}}", "./..."],
+ capture_output=True, text=True, timeout=30, check=True)
+ return set(result.stdout.splitlines())
+
+
+def compile_packages(base, head):
+ if not COMMIT.fullmatch(base) or not COMMIT.fullmatch(head):
+ return FULL
+ try:
+ if read_git("rev-parse", "--show-prefix").strip() or read_git("rev-parse", "HEAD").strip() != head.encode():
+ return FULL
+ read_git("diff", "--quiet", "--no-ext-diff", head, "--")
+ raw = read_git("diff", "--no-ext-diff", "--no-renames", "--raw", "--abbrev=40", "-z", base, head, "--")
+ tree = read_git("ls-tree", "-r", "--full-tree", "--name-only", "-z", head)
+ packages = changed_test_packages(raw, tree)
+ if packages != FULL:
+ # Match the root module's actual platform/build-tag inventory.
+ # An ignored or non-buildable directory is not a new invocation.
+ directories = root_package_directories()
+ if any(str(Path(package).resolve()) not in directories for package in packages):
+ return FULL
+ return packages
+ except (OSError, subprocess.CalledProcessError, subprocess.TimeoutExpired):
+ print("Exact test-only compilation scope unavailable; retaining full Go precompilation.", file=sys.stderr)
+ return FULL
+
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--base", required=True)
+ parser.add_argument("--head", required=True)
+ args = parser.parse_args()
+ print("\n".join(compile_packages(args.base, args.head)))
+
+
+if __name__ == "__main__":
+ main()
diff --git a/scripts/tests/test_go_test_compilation.py b/scripts/tests/test_go_test_compilation.py
index 853e8222ec..92840d6074 100644
--- a/scripts/tests/test_go_test_compilation.py
+++ b/scripts/tests/test_go_test_compilation.py
@@ -1,17 +1,24 @@
#!/usr/bin/env python3
"""Compilation admission must reject broken fixtures without executing tests."""
+import importlib.util
import os
from pathlib import Path
import re
+import shutil
import subprocess
import tempfile
import unittest
+from unittest.mock import patch
ROOT = Path(__file__).resolve().parents[2]
COMPILER = ROOT / "scripts/compile-go-tests.sh"
WORKFLOW = ROOT / ".github/workflows/build-and-test.yml"
+SELECTOR = ROOT / "scripts/select-go-test-compile-packages.py"
+SPEC = importlib.util.spec_from_file_location("go_compile_selection", SELECTOR)
+SELECTION = importlib.util.module_from_spec(SPEC)
+SPEC.loader.exec_module(SELECTION)
def job(source, name):
@@ -90,6 +97,7 @@ func TestStaleFixture(t *testing.T) { _ = api.Resource{Alerts: []api.ResourceAle
"go.mod", "go.sum", "internal/api/embed.json", "cmd/pulse/main.go",
"pkg/native/helper.c", "scripts/compile-go-tests.sh",
"scripts/go-test-compile-required.sh", "scripts/ensure_test_assets.sh",
+ "scripts/select-go-test-compile-packages.py",
".github/workflows/build-and-test.yml"]
irrelevant = ["frontend-modern/src/index.tsx", "frontend-modern/package-lock.json",
"docs/guide.md", "README.md", "scripts/unrelated.sh"]
@@ -122,10 +130,13 @@ func TestStaleFixture(t *testing.T) { _ = api.Resource{Alerts: []api.ResourceAle
"runs-on: ubuntu-24.04", "timeout-minutes: 15",
"persist-credentials: false", "go-version-file: go.mod",
"run: bash scripts/ensure_test_assets.sh", "run: bash scripts/compile-go-tests.sh",
+ "fetch-depth: 2", "PULSE_GO_COMPILE_HEAD: ${{ github.sha }}",
+ "PULSE_GO_COMPILE_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}",
):
self.assertIn(expected, compile_job)
self.assertLess(compile_job.index("ensure_test_assets.sh"), compile_job.index("compile-go-tests.sh"))
self.assertNotIn("continue-on-error:", compile_job)
+ self.assertIn("if: needs.changes.outputs.go_compile == 'true'", compile_job)
self.assertIn("go test -race -vet=off -count=1 -exec /bin/true ./...", COMPILER.read_text())
# Frontend work does not wait for the Go-only gate.
self.assertIn("needs: changes", job(source, "frontend"))
@@ -199,5 +210,212 @@ func TestStaleFixture(t *testing.T) { _ = api.Resource{Alerts: []api.ResourceAle
self.assertNotIn("passed", observed.stdout)
+class CompileSelectionTest(unittest.TestCase):
+ def raw(self, path=b"child/proof_test.go", status=b"M", old_mode=b"100644", new_mode=b"100644"):
+ old_blob = b"0" * 40 if status == b"A" else b"a" * 40
+ return b":" + old_mode + b" " + new_mode + b" " + old_blob + b" " + b"b" * 40 + b" " + status + b"\0" + path + b"\0"
+
+ def select(self, raw, *extra):
+ tree = b"go.mod\0child/proof_test.go\0" + b"".join(path + b"\0" for path in extra)
+ return SELECTION.changed_test_packages(raw, tree)
+
+ def test_complete_regular_test_diff_is_sorted_and_deduplicates_packages(self):
+ raw = self.raw() + self.raw(b"child/other_test.go", b"A", b"000000") + self.raw(b"root_test.go")
+ self.assertEqual(self.select(raw, b"child/other_test.go", b"root_test.go"), [".", "./child"])
+
+ def test_product_graph_control_docs_and_late_non_test_change_retain_full_compilation(self):
+ paths = [f"child/proof{index}_test.go".encode() for index in range(4000)]
+ raw = b"".join(self.raw(path) for path in paths)
+ self.assertEqual(self.select(raw, *paths), ["./child"])
+ for path in (b"go.mod", b"go.sum", b"internal/api/server.go", b"child/embed.json",
+ b".github/workflows/build-and-test.yml", b"docs/guide.md", b"install.sh",
+ b"scripts/compile-go-tests.sh", b"frontend-modern/src/App.tsx"):
+ with self.subTest(path=path):
+ self.assertEqual(self.select(raw + self.raw(path), *paths, path), SELECTION.FULL)
+ self.assertEqual(self.select(self.raw() + self.raw(path), path), SELECTION.FULL)
+
+ def test_deleted_renamed_symlink_noncanonical_and_ignored_paths_are_not_focused(self):
+ for raw in (self.raw(status=b"D", new_mode=b"000000"), self.raw(status=b"R100"),
+ self.raw(new_mode=b"120000"), self.raw(old_mode=b"100755")):
+ self.assertEqual(self.select(raw), SELECTION.FULL)
+ for path in (b"child/proof_test.go\ninternal/api/server.go", b"child/../proof_test.go",
+ b"/proof_test.go", b"-proof_test.go", b"child/_ignored_test.go",
+ b".ignored/proof_test.go", b"child/quoted\"_test.go", b"child/space name_test.go"):
+ with self.subTest(path=path):
+ self.assertEqual(self.select(self.raw(path), path), SELECTION.FULL)
+ for path in (b"vendor/child/proof_test.go", b"child/testdata/proof_test.go"):
+ self.assertEqual(self.select(self.raw(path), path), SELECTION.FULL)
+
+ def test_missing_empty_truncated_duplicate_or_inconsistent_evidence_is_not_focused(self):
+ for raw in (b"", self.raw()[:-1], b"malformed\0child/proof_test.go\0",
+ self.raw() + b"partial\0", self.raw() * 2,
+ self.raw(status=b"A"), self.raw(old_mode=b"000000")):
+ self.assertEqual(self.select(raw), SELECTION.FULL)
+ for tree in (b"", b"go.mod\0child/proof_test.go", b"child/proof_test.go\0",
+ b"go.mod\0", b"go.mod\0child/proof_test.go\0child/proof_test.go\0"):
+ self.assertEqual(SELECTION.changed_test_packages(self.raw(), tree), SELECTION.FULL)
+
+ def test_nested_module_and_workspace_are_not_root_module_test_changes(self):
+ self.assertEqual(self.select(self.raw(), b"child/go.mod"), SELECTION.FULL)
+ self.assertEqual(self.select(self.raw(), b"go.work"), SELECTION.FULL)
+ self.assertEqual(self.select(self.raw(), b"unrelated/go.mod"), ["./child"])
+
+ def test_unavailable_or_wrong_source_never_narrows(self):
+ for base, head in (("", "b" * 40), ("main", "b" * 40), ("a" * 40, "HEAD")):
+ with patch.object(SELECTION, "read_git") as read:
+ self.assertEqual(SELECTION.compile_packages(base, head), SELECTION.FULL)
+ read.assert_not_called()
+ for observations in ((b"nested/\n",), (b"\n", b"c" * 40 + b"\n")):
+ with patch.object(SELECTION, "read_git", side_effect=observations):
+ self.assertEqual(SELECTION.compile_packages("a" * 40, "b" * 40), SELECTION.FULL)
+ for error in (OSError("unavailable"), subprocess.CalledProcessError(1, "git"),
+ subprocess.TimeoutExpired("git", 30)):
+ with patch.object(SELECTION, "read_git", side_effect=error):
+ self.assertEqual(SELECTION.compile_packages("a" * 40, "b" * 40), SELECTION.FULL)
+
+ def test_source_diff_disables_renames_external_diff_and_abbreviation(self):
+ tree = b"go.mod\0child/proof_test.go\0"
+ with patch.object(SELECTION, "read_git", side_effect=[b"\n", b"b" * 40 + b"\n", b"", self.raw(), tree]) as read, \
+ patch.object(SELECTION, "root_package_directories", return_value={str(Path("child").resolve())}):
+ self.assertEqual(SELECTION.compile_packages("a" * 40, "b" * 40), ["./child"])
+ self.assertEqual(read.call_args_list[2].args, ("diff", "--quiet", "--no-ext-diff", "b" * 40, "--"))
+ self.assertEqual(read.call_args_list[3].args, (
+ "diff", "--no-ext-diff", "--no-renames", "--raw", "--abbrev=40", "-z", "a" * 40, "b" * 40, "--"))
+
+ def test_unlisted_or_unavailable_actual_root_packages_retain_full_compilation(self):
+ observations = [b"\n", b"b" * 40 + b"\n", b"", self.raw(), b"go.mod\0child/proof_test.go\0"]
+ with patch.object(SELECTION, "read_git", side_effect=observations), \
+ patch.object(SELECTION, "root_package_directories", return_value=set()):
+ self.assertEqual(SELECTION.compile_packages("a" * 40, "b" * 40), SELECTION.FULL)
+ with patch.object(SELECTION, "read_git", side_effect=observations), \
+ patch.object(SELECTION, "root_package_directories", side_effect=OSError("unavailable")):
+ self.assertEqual(SELECTION.compile_packages("a" * 40, "b" * 40), SELECTION.FULL)
+
+
+class ExactTreeCompileTest(unittest.TestCase):
+ def setUp(self):
+ self.temp = tempfile.TemporaryDirectory()
+ self.addCleanup(self.temp.cleanup)
+ self.root = Path(self.temp.name)
+ self.git("init", "-q", "--initial-branch=main")
+ self.write("go.mod", "module example.invalid/compileproof\n\ngo 1.24\n")
+ for script in (COMPILER, SELECTOR):
+ path = self.root / "scripts" / script.name
+ path.parent.mkdir(exist_ok=True)
+ shutil.copyfile(script, path)
+ self.write("api.go", "package compileproof\ntype Resource struct { ActiveAlerts []string }\n")
+ for package in ("child", "other"):
+ self.write(package + "/proof_test.go", '''package ''' + package + '''
+import ("os"; "testing")
+func record() { os.WriteFile(os.Getenv("CI_COMPILE_SENTINEL"), []byte("executed"), 0600) }
+func init() { record(); panic("initialiser must not execute") }
+func TestMain(m *testing.M) { record(); os.Exit(99) }
+func TestMustNotExecute(t *testing.T) { record(); t.Fatal("must not execute") }
+func ExampleMustNotExecute() { record(); panic("must not execute") }
+''')
+ self.base = self.commit()
+
+ def write(self, name, text):
+ path = self.root / name
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.write_text(text)
+
+ def git(self, *args):
+ return subprocess.check_output(
+ ["git", "-c", "user.name=CI fixture", "-c", "[email protected]",
+ "-c", "core.hooksPath=/dev/null", *args], cwd=self.root, stderr=subprocess.PIPE, text=True,
+ ).strip()
+
+ def commit(self):
+ self.git("add", "-A")
+ self.git("commit", "-q", "-m", "Fixture tree change")
+ return self.git("rev-parse", "HEAD")
+
+ def modify_test(self, suffix="\n// changed fixture\n"):
+ path = self.root / "child/proof_test.go"
+ path.write_text(path.read_text() + suffix)
+ return self.commit()
+
+ def plan(self, head, base=None):
+ result = subprocess.run(["python3", str(SELECTOR), "--base", base or self.base, "--head", head],
+ cwd=self.root, capture_output=True, text=True, check=True, timeout=10)
+ return result.stdout.strip()
+
+ def compile(self, head, base=None):
+ with tempfile.TemporaryDirectory() as evidence:
+ sentinel = Path(evidence) / "executed"
+ result = subprocess.run(
+ ["bash", str(self.root / "scripts/compile-go-tests.sh")], cwd=self.root,
+ env={**os.environ, "GOWORK": "off", "GOPROXY": "off", "CI_COMPILE_SENTINEL": str(sentinel),
+ "PULSE_GO_COMPILE_BASE": base or self.base, "PULSE_GO_COMPILE_HEAD": head},
+ capture_output=True, text=True, timeout=120,
+ )
+ self.assertFalse(sentinel.exists(), "compile gate executed fixture code")
+ return result
+
+ def test_real_added_and_modified_tests_compile_once_per_changed_package_without_execution(self):
+ self.write("child/added_test.go", "package child\n")
+ head = self.modify_test()
+ self.assertEqual(self.plan(head), "./child")
+ result = self.compile(head)
+ self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
+ self.assertIn("Compiling 1 changed-test package(s)", result.stdout)
+ self.assertIn("example.invalid/compileproof/child", result.stdout)
+ self.assertNotIn("example.invalid/compileproof/other", result.stdout)
+ self.assertIn("runtime tests remain required", result.stdout)
+
+ def test_real_broken_changed_test_is_rejected_before_execution(self):
+ head = self.modify_test("\nvar _ = removedAPI\n")
+ result = self.compile(head)
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn("removedAPI", result.stderr)
+ self.assertNotIn("runtime tests remain required", result.stdout)
+
+ def test_real_mixed_source_range_preserves_full_inert_compilation(self):
+ self.modify_test()
+ self.write("api.go", "package compileproof\ntype Resource struct { ActiveAlerts []string; Changed bool }\n")
+ head = self.commit()
+ self.assertEqual(self.plan(head), "./...")
+ result = self.compile(head)
+ self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
+ self.assertIn("Compiling all Go race-test binaries", result.stdout)
+ self.assertIn("example.invalid/compileproof/child", result.stdout)
+ self.assertIn("example.invalid/compileproof/other", result.stdout)
+
+ def test_real_deleted_renamed_symlink_and_nested_module_tests_use_full_plan(self):
+ (self.root / "child/proof_test.go").rename(self.root / "child/moved_test.go")
+ renamed = self.commit()
+ self.assertEqual(self.plan(renamed), "./...")
+ (self.root / "child/moved_test.go").unlink()
+ deleted = self.commit()
+ self.assertEqual(self.plan(deleted, renamed), "./...")
+ (self.root / "child/link_test.go").symlink_to("../other/proof_test.go")
+ linked = self.commit()
+ self.assertEqual(self.plan(linked, deleted), "./...")
+ self.write("nested/go.mod", "module example.invalid/nested\n\ngo 1.24\n")
+ self.write("nested/proof_test.go", "package nested\n")
+ nested_base = self.commit()
+ self.write("nested/proof_test.go", "package nested\n// changed\n")
+ self.assertEqual(self.plan(self.commit(), nested_base), "./...")
+
+ def test_real_empty_unknown_mismatching_and_subdirectory_source_use_full_plan(self):
+ self.assertEqual(self.plan(self.base), "./...")
+ head = self.modify_test()
+ self.assertEqual(self.plan(head, "0" * 40), "./...")
+ self.assertEqual(self.plan(self.base, head), "./...")
+ result = subprocess.run(["python3", str(SELECTOR), "--base", self.base, "--head", head],
+ cwd=self.root / "child", capture_output=True, text=True, check=True)
+ self.assertEqual(result.stdout.strip(), "./...")
+
+ def test_broken_empty_or_invalid_selector_cannot_admit_success_without_compilation(self):
+ head = self.modify_test()
+ for body in ("raise SystemExit(7)\n", "", "print('--help')\n", "print('./../outside')\n"):
+ with self.subTest(body=body):
+ self.write("scripts/select-go-test-compile-packages.py", body)
+ result = self.compile(head)
+ self.assertNotEqual(result.returncode, 0)
+ self.assertNotIn("runtime tests remain required", result.stdout)
+
+
if __name__ == "__main__":
unittest.main()