aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2022-09-20 23:00:27 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2022-09-28 17:59:43 +0300
commit744e8215261fbf81b9348d115d4916a9c88b52cc (patch)
tree9b78941d4ea67fefdccca98215b1340dd2dd6c99 /tests
parente59b4fc15eef3b3d0af5b81190b1e54f270ee2d2 (diff)
Add support for 'while' loop in script
Diffstat (limited to 'tests')
-rw-r--r--tests/recipe/buildscript/testscript54
-rw-r--r--tests/test/script/runner/pipe.testscript8
-rw-r--r--tests/test/script/runner/redirect.testscript4
-rw-r--r--tests/test/script/runner/while.testscript16
4 files changed, 62 insertions, 20 deletions
diff --git a/tests/recipe/buildscript/testscript b/tests/recipe/buildscript/testscript
index 0bf752e..54c3bbe 100644
--- a/tests/recipe/buildscript/testscript
+++ b/tests/recipe/buildscript/testscript
@@ -487,7 +487,7 @@ posix = ($cxx.target.class != 'windows')
: normal
:
{
- cat <<EOI >=bar.h;
+ cat <<EOI >=bar.h;
bar
EOI
@@ -519,23 +519,23 @@ posix = ($cxx.target.class != 'windows')
}}
EOI
- $* 2>>EOE;
+ $* 2>>EOE;
gen h{baz.h}
gen h{foo.h}
EOE
- cat foo.h >>EOO;
- bar
- baz
- EOO
+ cat foo.h >>EOO;
+ bar
+ baz
+ EOO
- $* clean 2>-
+ $* clean 2>-
}
: byproduct
:
{
- cat <<EOI >=bar.h;
+ cat <<EOI >=bar.h;
bar
EOI
@@ -562,17 +562,17 @@ posix = ($cxx.target.class != 'windows')
}}
EOI
- $* 2>>EOE;
+ $* 2>>EOE;
gen h{baz.h}
gen h{foo.h}
EOE
- cat foo.h >>EOO;
- bar
- baz
- EOO
+ cat foo.h >>EOO;
+ bar
+ baz
+ EOO
- $* clean 2>-
+ $* clean 2>-
}
}
}
@@ -885,3 +885,29 @@ if $posix
alias{bar} alias{far}
EOE
}
+
+: flow-control-construct
+:
+{
+ : while
+ :
+ {
+ echo 'bar' >=bar;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ p = $path($>)
+ while test -f $p != 0
+ cp $path($<) $p
+ end
+ }}
+ EOI
+
+ $* 2>'cp file{foo}';
+
+ cat <<<foo >'bar';
+
+ $* clean 2>-
+ }
+}
diff --git a/tests/test/script/runner/pipe.testscript b/tests/test/script/runner/pipe.testscript
index 205fd55..92ab33e 100644
--- a/tests/test/script/runner/pipe.testscript
+++ b/tests/test/script/runner/pipe.testscript
@@ -17,7 +17,7 @@ $c <'$* -o foo | cat >foo' && $b : process-to-builtin
:
$c <'$* -o foo -s 1 | $* -i 1 >foo -s 2' && $b 2>>/~%EOE% != 0
%testscript:1:1: error: .+ exited with code 2%
- info: stdout: test/1/stdout-2
+ info: stdout: test/1/stdout-c2
info: test id: 1
EOE
@@ -25,9 +25,9 @@ $c <'$* -o foo | cat >foo' && $b : process-to-builtin
:
$c <'$* -o foo -e foo 2>bar | $* -i 2 2>baz' && $b 2>>/~%EOE% != 0
%testscript:1:1: error: .+ stderr doesn't match expected%
- info: stderr: test/1/stderr-2
- info: expected stderr: test/1/stderr-2.orig
- info: stderr diff: test/1/stderr-2.diff
+ info: stderr: test/1/stderr-c2
+ info: expected stderr: test/1/stderr-c2.orig
+ info: stderr diff: test/1/stderr-c2.diff
%.{3}
-baz
+foo
diff --git a/tests/test/script/runner/redirect.testscript b/tests/test/script/runner/redirect.testscript
index 0fe3aa3..209c4ce 100644
--- a/tests/test/script/runner/redirect.testscript
+++ b/tests/test/script/runner/redirect.testscript
@@ -654,9 +654,9 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex.
$* -o bar >?out
EOI
%testscript:2: error: ../../../../../driver(.exe)? stdout doesn't match expected%
- info: stdout: test/1/stdout-2
+ info: stdout: test/1/stdout-n2
info: expected stdout: test/1/out
- info: stdout diff: test/1/stdout-2.diff
+ info: stdout diff: test/1/stdout-n2.diff
%--- \.*%
%\+\+\+ \.*%
%@@ \.*%
diff --git a/tests/test/script/runner/while.testscript b/tests/test/script/runner/while.testscript
new file mode 100644
index 0000000..1c58827
--- /dev/null
+++ b/tests/test/script/runner/while.testscript
@@ -0,0 +1,16 @@
+# file : tests/test/script/runner/while.testscript
+# license : MIT; see accompanying LICENSE file
+
+.include ../common.testscript
+
+: basics
+:
+$c <<EOI && $b >>EOO
+ while ($v != "aa")
+ echo "$v" >|
+ v = "$(v)a"
+ end
+ EOI
+
+ a
+ EOO