aboutsummaryrefslogtreecommitdiff
path: root/tests/function/process/testscript
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-06-20 09:51:56 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-06-20 09:51:56 +0200
commit353438a94953bf4d093af0d84decd5ec7529ed34 (patch)
tree4c4e376ff8d831e85954a9b74f2157ad4b06351a /tests/function/process/testscript
parentc6b3f6659eda9b0b255ddc2d24accdd998b5938d (diff)
Add $process.run() and $process.run_regex() functions
$process.run(<prog>[ <args>...]) Return trimmed stdout. $process.run_regex(<prog>[ <args>...], <pat> [, <fmt>]) Return stdout lines matched and optionally processed with regex. Each line of stdout (including the customary trailing blank) is matched (as a whole) against <pat> and, if successful, returned, optionally processed with <fmt>, as an element of a list.
Diffstat (limited to 'tests/function/process/testscript')
-rw-r--r--tests/function/process/testscript30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/function/process/testscript b/tests/function/process/testscript
new file mode 100644
index 0000000..f01af6f
--- /dev/null
+++ b/tests/function/process/testscript
@@ -0,0 +1,30 @@
+# file : tests/function/process/testscript
+# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+.include ../../common.test
+
+: run
+:
+$* <<EOI >>~/EOO/
+print $process.run($build.path --version)
+EOI
+/build2 .+/
+/.+/*
+EOO
+
+: run-regex-match
+:
+$* <<EOI >>~/EOO/
+print $process.run_regex($build.path --version, 'build2 .+')
+EOI
+/build2 .+/
+EOO
+
+: run-regex-replace
+:
+$* <<EOI >>~/EOO/
+print $process.run_regex($build.path --version, 'build2 ([0-9.]+).*', '\1')
+EOI
+/[0-9]+.[0-9]+.[0-9]+/d
+EOO