From bcf9975fa19050e07d6724992a75ebde4b0156c5 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 8 Oct 2021 20:58:22 +0100 Subject: tests: Fix up use of absolute paths for false/true/echo etc. Signed-off-by: Daniel Silverstone --- subplotlib/runcmd.md | 24 ++++++++++++------------ subplotlib/tests/runcmd.rs | 40 ++++++++++++++++++++-------------------- tests/python/daemon.md | 18 +++++++++--------- tests/python/runcmd.md | 24 ++++++++++++------------ 4 files changed, 53 insertions(+), 53 deletions(-) diff --git a/subplotlib/runcmd.md b/subplotlib/runcmd.md index d6210fb..50e41f6 100644 --- a/subplotlib/runcmd.md +++ b/subplotlib/runcmd.md @@ -22,8 +22,8 @@ they're verified. It uses the steps and functions from the command, then examine the exit code, standard output (stdout for short), or standard error output (stderr) of the command. -The scenarios use the Unix commands `/bin/true` and `/bin/false` to -generate exit codes, and `/bin/echo` to produce stdout. To generate +The scenarios use the Unix commands `true` and `false` to +generate exit codes, and `echo` to produce stdout. To generate stderr, they use the little helper script below. ```{#err.sh .file .sh .numberLines} @@ -40,7 +40,7 @@ variations. ## Successful execution ```scenario -when I run /bin/true +when I run true then exit code is 0 and command is successful ``` @@ -49,7 +49,7 @@ and command is successful ```scenario given a directory xyzzy -when I run, in xyzzy, /bin/pwd +when I run, in xyzzy, pwd then exit code is 0 then command is successful then stdout contains "/xyzzy" @@ -58,7 +58,7 @@ then stdout contains "/xyzzy" ## Failed execution ```scenario -when I try to run /bin/false +when I try to run false then exit code is not 0 and command fails ``` @@ -67,7 +67,7 @@ and command fails ```scenario given a directory xyzzy -when I try to run, in xyzzy, /bin/false +when I try to run, in xyzzy, false then exit code is not 0 and command fails ``` @@ -84,7 +84,7 @@ to the reader what's inside. Also, C-style string escapes are understood. ```scenario -when I run /bin/echo hello, world +when I run echo hello, world then stdout is exactly "hello, world\n" ``` @@ -102,7 +102,7 @@ Exact string comparisons are not always enough, so we can verify a sub-string is in output. ```scenario -when I run /bin/echo hello, world +when I run echo hello, world then stdout contains "world\n" and exit code is 0 ``` @@ -122,7 +122,7 @@ regular expression. Note that the regular expression is not delimited and does not get any C-style string escaped decoded. ```scenario -when I run /bin/echo hello, world +when I run echo hello, world then stdout matches regex world$ ``` @@ -142,7 +142,7 @@ have something we want to avoid. ## Check stdout is not exactly something ```scenario -when I run /bin/echo hi +when I run echo hi then stdout isn't exactly "hello, world\n" ``` @@ -157,7 +157,7 @@ then stderr isn't exactly "hello, world\n" ## Check stdout doesn't contain sub-string ```scenario -when I run /bin/echo hi +when I run echo hi then stdout doesn't contain "world" ``` @@ -172,7 +172,7 @@ then stderr doesn't contain "world" ## Check stdout doesn't match regular expression ```scenario -when I run /bin/echo hi +when I run echo hi then stdout doesn't match regex world$ ``` diff --git a/subplotlib/tests/runcmd.rs b/subplotlib/tests/runcmd.rs index f18f463..0c677ba 100644 --- a/subplotlib/tests/runcmd.rs +++ b/subplotlib/tests/runcmd.rs @@ -18,8 +18,8 @@ fn successful_execution() { let step = subplotlib::steplibrary::runcmd::run::Builder::default() .argv0( - // "/bin/true" - &base64_decode("L2Jpbi90cnVl"), + // "true" + &base64_decode("dHJ1ZQ=="), ) .args( // "" @@ -62,8 +62,8 @@ fn successful_execution_in_a_sub_directory() { &base64_decode("eHl6enk="), ) .argv0( - // "/bin/pwd" - &base64_decode("L2Jpbi9wd2Q="), + // "pwd" + &base64_decode("cHdk"), ) .args( // "" @@ -100,8 +100,8 @@ fn failed_execution() { let step = subplotlib::steplibrary::runcmd::try_to_run::Builder::default() .argv0( - // "/bin/false" - &base64_decode("L2Jpbi9mYWxzZQ=="), + // "false" + &base64_decode("ZmFsc2U="), ) .args( // "" @@ -144,8 +144,8 @@ fn failed_execution_in_a_sub_directory() { &base64_decode("eHl6enk="), ) .argv0( - // "/bin/false" - &base64_decode("L2Jpbi9mYWxzZQ=="), + // "false" + &base64_decode("ZmFsc2U="), ) .args( // "" @@ -176,8 +176,8 @@ fn check_stdout_is_exactly_as_wanted() { let step = subplotlib::steplibrary::runcmd::run::Builder::default() .argv0( - // "/bin/echo" - &base64_decode("L2Jpbi9lY2hv"), + // "echo" + &base64_decode("ZWNobw=="), ) .args( // " hello, world" @@ -254,8 +254,8 @@ fn check_stdout_using_sub_string_search() { let step = subplotlib::steplibrary::runcmd::run::Builder::default() .argv0( - // "/bin/echo" - &base64_decode("L2Jpbi9lY2hv"), + // "echo" + &base64_decode("ZWNobw=="), ) .args( // " hello, world" @@ -337,8 +337,8 @@ fn check_stdout_using_regular_expressions() { let step = subplotlib::steplibrary::runcmd::run::Builder::default() .argv0( - // "/bin/echo" - &base64_decode("L2Jpbi9lY2hv"), + // "echo" + &base64_decode("ZWNobw=="), ) .args( // " hello, world" @@ -415,8 +415,8 @@ fn check_stdout_is_not_exactly_something() { let step = subplotlib::steplibrary::runcmd::run::Builder::default() .argv0( - // "/bin/echo" - &base64_decode("L2Jpbi9lY2hv"), + // "echo" + &base64_decode("ZWNobw=="), ) .args( // " hi" @@ -493,8 +493,8 @@ fn check_stdout_doesn_t_contain_sub_string() { let step = subplotlib::steplibrary::runcmd::run::Builder::default() .argv0( - // "/bin/echo" - &base64_decode("L2Jpbi9lY2hv"), + // "echo" + &base64_decode("ZWNobw=="), ) .args( // " hi" @@ -571,8 +571,8 @@ fn check_stdout_doesn_t_match_regular_expression() { let step = subplotlib::steplibrary::runcmd::run::Builder::default() .argv0( - // "/bin/echo" - &base64_decode("L2Jpbi9lY2hv"), + // "echo" + &base64_decode("ZWNobw=="), ) .args( // " hi" diff --git a/tests/python/daemon.md b/tests/python/daemon.md index 285f9f8..6d9b8f4 100644 --- a/tests/python/daemon.md +++ b/tests/python/daemon.md @@ -17,11 +17,11 @@ This scenario starts a background process, verifies it's started, and verifies it's terminated after the scenario ends. ~~~scenario -given there is no "/bin/sleep 12765" process -when I start "/bin/sleep 12765" as a background process as sleepyhead -then a process "/bin/sleep 12765" is running +given there is no "sleep 12765" process +when I start "sleep 12765" as a background process as sleepyhead +then a process "sleep 12765" is running when I stop background process sleepyhead -then there is no "/bin/sleep 12765" process +then there is no "sleep 12765" process ~~~ @@ -68,12 +68,12 @@ This scenario verifies that if the background process never starts listening on its port, the daemon library handles that correctly. ~~~scenario -given there is no "/bin/sleep 12765" process -when I try to start "/bin/sleep 12765" as sleepyhead, on port 8888 +given there is no "sleep 12765" process +when I try to start "sleep 12765" as sleepyhead, on port 8888 then starting daemon fails with "ConnectionRefusedError" -then a process "/bin/sleep 12765" is running +then a process "sleep 12765" is running when I stop background process sleepyhead -then there is no "/bin/sleep 12765" process +then there is no "sleep 12765" process ~~~ @@ -101,7 +101,7 @@ have had time to produce it yet. ~~~{#chatty-daemon.sh .file .sh .numberLines} -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail diff --git a/tests/python/runcmd.md b/tests/python/runcmd.md index 68465a8..7b88dd3 100644 --- a/tests/python/runcmd.md +++ b/tests/python/runcmd.md @@ -14,8 +14,8 @@ they're verified. It uses the steps and functions from the command, then examine the exit code, standard output (stdout for short), or standard error output (stderr) of the command. -The scenarios use the Unix commands `/bin/true` and `/bin/false` to -generate exit codes, and `/bin/echo` to produce stdout. To generate +The scenarios use the Unix commands `true` and `false` to +generate exit codes, and `echo` to produce stdout. To generate stderr, they use the little helper script below. ~~~{#err.sh .file .sh .numberLines} @@ -32,7 +32,7 @@ variations. ## Successful execution ~~~scenario -when I run /bin/true +when I run true then exit code is 0 and command is successful ~~~ @@ -41,7 +41,7 @@ and command is successful ~~~scenario given a directory xyzzy -when I run, in xyzzy, /bin/pwd +when I run, in xyzzy, pwd then exit code is 0 then command is successful then stdout contains "/xyzzy" @@ -50,7 +50,7 @@ then stdout contains "/xyzzy" ## Failed execution ~~~scenario -when I try to run /bin/false +when I try to run false then exit code is not 0 and command fails ~~~ @@ -59,7 +59,7 @@ and command fails ~~~scenario given a directory xyzzy -when I try to run, in xyzzy, /bin/false +when I try to run, in xyzzy, false then exit code is not 0 and command fails ~~~ @@ -97,7 +97,7 @@ to the reader what's inside. Also, C-style string escapes are understood. ~~~scenario -when I run /bin/echo hello, world +when I run echo hello, world then stdout is exactly "hello, world\n" ~~~ @@ -115,7 +115,7 @@ Exact string comparisons are not always enough, so we can verify a sub-string is in output. ~~~scenario -when I run /bin/echo hello, world +when I run echo hello, world then stdout contains "world\n" and exit code is 0 ~~~ @@ -135,7 +135,7 @@ regular expression. Note that the regular expression is not delimited and does not get any C-style string escaped decoded. ~~~scenario -when I run /bin/echo hello, world +when I run echo hello, world then stdout matches regex world$ ~~~ @@ -155,7 +155,7 @@ have something we want to avoid. ## Check stdout is not exactly something ~~~scenario -when I run /bin/echo hi +when I run echo hi then stdout isn't exactly "hello, world\n" ~~~ @@ -170,7 +170,7 @@ then stderr isn't exactly "hello, world\n" ## Check stdout doesn't contain sub-string ~~~scenario -when I run /bin/echo hi +when I run echo hi then stdout doesn't contain "world" ~~~ @@ -185,7 +185,7 @@ then stderr doesn't contain "world" ## Check stdout doesn't match regular expression ~~~scenario -when I run /bin/echo hi +when I run echo hi then stdout doesn't match regex world$ ~~~ -- cgit v1.2.1