tests/functional2: migrate timeout.sh
Change-Id: Ieb12c46bc987c74a6adda07e6c6ed33aebf8a96c
This commit is contained in:
@@ -72,7 +72,6 @@ functional_tests_scripts = [
|
||||
'repair-chroot.sh',
|
||||
'fixed.sh',
|
||||
'export-graph.sh',
|
||||
'timeout.sh',
|
||||
'fetchGitRefs.sh',
|
||||
'gc-runtime.sh',
|
||||
'tarball.sh',
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
# Test the `--timeout' option.
|
||||
|
||||
source common.sh
|
||||
|
||||
# XXX: This shouldn’t be, but #4813 cause this test to fail
|
||||
needLocalStore "see #4813"
|
||||
|
||||
messages=$(nix-build -Q timeout.nix -A infiniteLoop --timeout 2 2>&1) && status=0 || status=$?
|
||||
|
||||
if [ $status -ne 101 ]; then
|
||||
echo "error: 'nix-store' exited with '$status'; should have exited 101"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if echo "$messages" | grepQuietInverse "timed out"; then
|
||||
echo "error: build may have failed for reasons other than timeout; output:"
|
||||
echo "$messages" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if nix-build -Q timeout.nix -A infiniteLoop --max-build-log-size 100; then
|
||||
echo "build should have failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if nix-build timeout.nix -A silent --max-silent-time 2; then
|
||||
echo "build should have failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if nix-build timeout.nix -A closeLog; then
|
||||
echo "build should have failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if nix build -f timeout.nix silent --max-silent-time 2; then
|
||||
echo "build should have failed"
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,50 @@
|
||||
from functional2.testlib.fixtures.file_helper import with_files, CopyFile
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset
|
||||
|
||||
_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)
|
||||
)
|
||||
assert "timed out" in res.stderr_plain
|
||||
|
||||
|
||||
@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)
|
||||
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)
|
||||
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
|
||||
Reference in New Issue
Block a user