fixing tests
This commit is contained in:
1 parent
ab8260a5d0
commit
708a02a6d5
3 files changed
+35
-3
No files matched your search
@@ -49,6 +49,13 @@ in
|
||||
pkgs.testers.runNixOSTest {
|
||||
name = "hermenix-migrate-connections";
|
||||
|
||||
# This test only boots once and copies a few small files locally — it
|
||||
# should finish in well under a minute. Bound it far below the framework's
|
||||
# 1-hour default so a regression (e.g. a prompt silently blocking on
|
||||
# terminal input instead of reading piped stdin) fails fast instead of
|
||||
# burning a full hour before being reported.
|
||||
globalTimeout = 300;
|
||||
|
||||
nodes.machine = {
|
||||
environment.systemPackages = [ hermenix ];
|
||||
};
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
pkgs.testers.runNixOSTest {
|
||||
name = "hermenix-guest-config";
|
||||
|
||||
# This test boots, reboots once, and runs only quick local checks — a few
|
||||
# minutes is generous. Bound it far below the framework's 1-hour default so
|
||||
# a genuine hang (boot failure, a blocked prompt, a stuck reboot) fails
|
||||
# fast instead of burning a full hour before being reported.
|
||||
globalTimeout = 600;
|
||||
|
||||
nodes.machine =
|
||||
{ lib, ... }:
|
||||
{
|
||||
|
||||
+22
-3
@@ -19,19 +19,38 @@ def die [msg: string] {
|
||||
}
|
||||
def step [n: int, title: string] { print $"\n(ansi attr_bold)== ($n). ($title)(ansi reset)" }
|
||||
|
||||
# Read a line of user input. On a real terminal this prompts interactively
|
||||
# via `input`. When stdin isn't a terminal (e.g. piped in from a test or
|
||||
# script), `input` would otherwise try to read from the controlling terminal
|
||||
# and hang forever waiting for a keystroke that never comes — so read the
|
||||
# piped stdin directly instead.
|
||||
def read-line [prompt: string] {
|
||||
if (is-terminal --stdin) {
|
||||
input $prompt
|
||||
} else {
|
||||
print -n $prompt
|
||||
(
|
||||
^cat
|
||||
| lines
|
||||
| first
|
||||
| str trim
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
def ask [prompt: string, default: string = ""] {
|
||||
let suffix = if $default != "" { $" [($default)]" } else { "" }
|
||||
let reply = (input $" ($prompt)($suffix): ")
|
||||
let reply = (read-line $" ($prompt)($suffix): ")
|
||||
if $reply == "" { $default } else { $reply }
|
||||
}
|
||||
|
||||
def confirm [prompt: string] {
|
||||
let reply = (input $" ($prompt) [y/N] ")
|
||||
let reply = (read-line $" ($prompt) [y/N] ")
|
||||
(($reply | str starts-with "y") or ($reply | str starts-with "Y"))
|
||||
}
|
||||
|
||||
def confirm-word [word: string, prompt: string] {
|
||||
(input $" ($prompt) ") == $word
|
||||
(read-line $" ($prompt) ") == $word
|
||||
}
|
||||
|
||||
# Single-quote a string for safe embedding in a remote shell command line.
|
||||
|
||||
Reference in new issue
Block a user