this fixes a large portion of tests currently marked no_daemon. most of them only needed to set some trusted settings, which is easily done now Change-Id: Id5a5ee94951cdc92bddd2264c738ca4f98980c8b
61 lines
1.7 KiB
Python
61 lines
1.7 KiB
Python
from testlib.fixtures.file_helper import with_files, CopyFile
|
|
from testlib.fixtures.nix import Nix
|
|
from testlib.utils import get_global_asset
|
|
import pytest
|
|
|
|
_files = {
|
|
"timeout.nix": CopyFile("assets/test_timeout/timeout.nix"),
|
|
"config.nix": get_global_asset("config.nix"),
|
|
}
|
|
|
|
|
|
@with_files(_files)
|
|
def test_timeout_timeout(nix: Nix):
|
|
res = (
|
|
nix.nix_build(["-Q", "timeout.nix", "-A", "infiniteLoop", "--timeout", "2"])
|
|
.run()
|
|
.expect(101 if not nix.uses_daemon else 1)
|
|
)
|
|
assert "timed out" in res.stderr_plain
|
|
|
|
|
|
@pytest.mark.nix_settings(trusted_users="*")
|
|
@with_files(_files)
|
|
def test_timeout_max_log(nix: Nix):
|
|
res = (
|
|
nix.nix_build(["-Q", "timeout.nix", "-A", "infiniteLoop", "--max-build-log-size", "100"])
|
|
.run()
|
|
.expect(1)
|
|
)
|
|
assert "killed after writing more than 100 bytes of log output" in res.stderr_plain
|
|
|
|
|
|
@with_files(_files)
|
|
def test_timeout_silent(nix: Nix):
|
|
res = (
|
|
nix.nix_build(["timeout.nix", "-A", "silent", "--max-silent-time", "2"])
|
|
.run()
|
|
.expect(101 if not nix.uses_daemon else 1)
|
|
)
|
|
assert "file timed out after 2 seconds of silence" in res.stderr_plain
|
|
|
|
|
|
@with_files(_files)
|
|
def test_timeout_close_log(nix: Nix):
|
|
res = (
|
|
nix.nix_build(["timeout.nix", "-A", "closeLog"])
|
|
.run()
|
|
.expect(100 if not nix.uses_daemon else 1)
|
|
)
|
|
assert "failed due to signal 9 (Killed" in res.stderr_plain
|
|
|
|
|
|
@with_files(_files)
|
|
def test_timeout_nix3_silent(nix: Nix):
|
|
res = (
|
|
nix.nix(["build", "-f", "timeout.nix", "silent", "--max-silent-time", "2"], flake=True)
|
|
.run()
|
|
.expect(1)
|
|
)
|
|
assert "from .drv file timed out after 2 seconds of silence" in res.stderr_plain
|