Answer stability round 1: 0 🔴, 2 🟡 (0 misread); run CI's image untagged and state where the socket must be
This commit is contained in:
@@ -94,7 +94,7 @@ class RunHeavy(unittest.TestCase):
|
||||
|
||||
def test_a_docker_run_without_limits_gets_three_quarters_of_the_memory_split_across_the_slots(self):
|
||||
memory = read_memory()
|
||||
assert memory is not None, "this test reads the share from /proc/meminfo, which only Linux has"
|
||||
assert memory is not None, "this test needs MemTotal and MemAvailable from /proc/meminfo: run it on Linux"
|
||||
share = f"{memory.total * 3 // 4 // slot_count(usable_cpus()) // 1024}m"
|
||||
result = self.run_tool("docker", "run", "--rm", "img", "true", env=self.fake_docker())
|
||||
self.assertEqual((result.returncode, result.stdout), (0, f"run --memory {share} --memory-swap {share} --rm img true\n"))
|
||||
|
||||
@@ -13,7 +13,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
from run_tests import main
|
||||
|
||||
BIN = pathlib.Path(__file__).resolve().parents[1]
|
||||
# The pytest and pytest-xdist run-tests pins, without its worker count, so the tests run them whether or not the interpreter running the tests has pytest.
|
||||
# run-tests' own pytest command, without its worker count. uvx fetches pytest for it, so the Run tests need no pytest installed.
|
||||
PYTEST_PINNED = [*main.PYTEST[:main.PYTEST.index("-n")], "-p", "no:cacheprovider"]
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ class Run(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
pathlib.Path(folder, "test_ok.py").write_text("def test_ok():\n\tprint('noise from a passing test')\n")
|
||||
code, output = self.run_in(folder, PYTEST_PINNED, "-s", folder)
|
||||
self.assertEqual(code, 0)
|
||||
self.assertEqual(code, 0, output)
|
||||
lines = output.rstrip("\n").splitlines()
|
||||
self.assertEqual(len(lines), 2, output)
|
||||
self.assertRegex(lines[0], r"^=+ 1 passed in .* =+$")
|
||||
|
||||
+2
-2
@@ -8,6 +8,6 @@ def isolated_env() -> dict[str, str]:
|
||||
return {name: value for name, value in os.environ.items() if not name.startswith(("GIT_", "LOOP_CLAUDE_", "PYTHON")) and name != "CLAUDE_CODE_SANDBOXED"}
|
||||
|
||||
|
||||
# Root ignores file permissions, so a test that makes a file unreadable or a folder read-only needs another user.
|
||||
# Call it first in a test that takes a file's or a folder's permissions away.
|
||||
def assert_not_root(test: unittest.TestCase) -> None:
|
||||
test.assertNotEqual(os.geteuid(), 0, "this test needs file permissions to bind it, which they don't for root: run the tests as another user")
|
||||
test.assertNotEqual(os.geteuid(), 0, "root ignores file permissions, which this test checks: run the tests as a user other than root")
|
||||
|
||||
Reference in New Issue
Block a user