diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-02-07 10:10:32 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-02-07 10:59:11 +0200 |
commit | 4830fd3246eca2e7baaaee18c4e0804bb4f4bbc6 (patch) | |
tree | 209282d94a913bd17df745ec983e69bd0a55bd33 /share | |
parent | d536150cc444239dce255eff9e81072197c53cf7 (diff) | |
download | subplot-4830fd3246eca2e7baaaee18c4e0804bb4f4bbc6.tar.gz |
test(lib/runcmd): verify that runcmd_prepend_to_path works
Diffstat (limited to 'share')
-rw-r--r-- | share/python/lib/runcmd.md | 24 | ||||
-rw-r--r-- | share/python/lib/runcmd_test.py | 15 | ||||
-rw-r--r-- | share/python/lib/runcmd_test.yaml | 5 |
3 files changed, 44 insertions, 0 deletions
diff --git a/share/python/lib/runcmd.md b/share/python/lib/runcmd.md index a9d4ed4..4615f69 100644 --- a/share/python/lib/runcmd.md +++ b/share/python/lib/runcmd.md @@ -45,6 +45,27 @@ then exit code is not 0 and command fails ~~~ +# Check we can prepend to $PATH + +This scenario verifies that we can add a directory to the beginning of +the PATH environment variable, so that we can have `runcmd` invoke a +binary from our build tree rather than from system directories. This +is especially useful for testing new versions of software that's +already installed on the system. + +~~~scenario +given executable script ls from ls.sh +when I prepend . to PATH +when I run ls +then command is successful +then stdout contains "custom ls, not system ls" +~~~ + +~~~{#ls.sh .file .sh .numberLines} +#!/bin/sh +echo "custom ls, not system ls" +~~~ + # Check output has what we want These scenarios verify that stdout or stderr do have something we want @@ -165,6 +186,9 @@ author: The Subplot project template: python bindings: - runcmd.yaml +- runcmd_test.yaml functions: - runcmd.py +- runcmd_test.py +- files.py ... diff --git a/share/python/lib/runcmd_test.py b/share/python/lib/runcmd_test.py new file mode 100644 index 0000000..6aa435a --- /dev/null +++ b/share/python/lib/runcmd_test.py @@ -0,0 +1,15 @@ +import os + + +def create_script_from_embedded(ctx, filename=None, embedded=None): + files_create_from_embedded_with_other_name = globals()[ + "files_create_from_embedded_with_other_name" + ] + + # Create the file. + files_create_from_embedded_with_other_name( + ctx, filename_on_disk=filename, embedded_filename=embedded + ) + + # Make the new file executable. + os.chmod(filename, 0o755) diff --git a/share/python/lib/runcmd_test.yaml b/share/python/lib/runcmd_test.yaml new file mode 100644 index 0000000..8ade220 --- /dev/null +++ b/share/python/lib/runcmd_test.yaml @@ -0,0 +1,5 @@ +- given: "executable script {filename} from {embedded}" + function: create_script_from_embedded + +- when: "I prepend {dirname} to PATH" + function: runcmd_prepend_to_path |