From 353438a94953bf4d093af0d84decd5ec7529ed34 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 20 Jun 2018 09:51:56 +0200 Subject: Add $process.run() and $process.run_regex() functions $process.run([ ...]) Return trimmed stdout. $process.run_regex([ ...], [, ]) Return stdout lines matched and optionally processed with regex. Each line of stdout (including the customary trailing blank) is matched (as a whole) against and, if successful, returned, optionally processed with , as an element of a list. --- tests/function/process/buildfile | 5 +++++ tests/function/process/testscript | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tests/function/process/buildfile create mode 100644 tests/function/process/testscript (limited to 'tests/function') diff --git a/tests/function/process/buildfile b/tests/function/process/buildfile new file mode 100644 index 0000000..4ea4742 --- /dev/null +++ b/tests/function/process/buildfile @@ -0,0 +1,5 @@ +# file : tests/function/process/buildfile +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +./: testscript $b 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 +: +$* <>~/EOO/ +print $process.run($build.path --version) +EOI +/build2 .+/ +/.+/* +EOO + +: run-regex-match +: +$* <>~/EOO/ +print $process.run_regex($build.path --version, 'build2 .+') +EOI +/build2 .+/ +EOO + +: run-regex-replace +: +$* <>~/EOO/ +print $process.run_regex($build.path --version, 'build2 ([0-9.]+).*', '\1') +EOI +/[0-9]+.[0-9]+.[0-9]+/d +EOO -- cgit v1.1