aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-12-01 22:26:06 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2016-12-05 17:21:48 +0300
commit66eea6d40b7fd2c12b297f7ce55a62e02f4db291 (patch)
treeb32027be37054d110f52b8280cf8d2b959c78921 /tests
parentcaf24aa705243f87c83d346d803adf84888a3cc5 (diff)
Make use of casts and canonicalizations in testscripts
Diffstat (limited to 'tests')
-rw-r--r--tests/test/script/builtin/rm.test16
-rw-r--r--tests/test/script/integration/testscript27
-rw-r--r--tests/test/script/runner/cleanup.test68
-rw-r--r--tests/test/script/runner/status.test4
-rw-r--r--tests/value/reverse.test10
5 files changed, 62 insertions, 63 deletions
diff --git a/tests/test/script/builtin/rm.test b/tests/test/script/builtin/rm.test
index 31dfca0..bb12827 100644
--- a/tests/test/script/builtin/rm.test
+++ b/tests/test/script/builtin/rm.test
@@ -2,11 +2,7 @@
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
-+if ($cxx.target.class != windows) # @@ TMP trailing separator
- s = '/'
-else
- s = '\'
-end
+td = $~
: no-args
:
@@ -63,19 +59,19 @@ rm -r a
:
: Removing scope directory fails.
:
-rm -r ./ 2>"rm: '$~$s' contains scope working directory" == 1
+rm -r ./ 2>"rm: '([string] $~)' contains test working directory '$~'" == 1
: outside-scope
:
-: Removing path outside the script working directory fails. Need to use a path
-: that unlikely exists (not to remove something useful).
+: Removing path outside the testscript working directory fails. Need to use a
+: path that unlikely exists (not to remove something useful).
:
:
-rm ../../a/b/c 2>"rm: '$normalize([path] $~/../../a/b/c)' is outside script working directory" == 1
+rm ../../a/b/c 2>"rm: '$normalize([path] $~/../../a/b/c)' is out of working directory '$td'" == 1
: outside-scope-force
:
-: Removing path outside the script scope working directory succeeds with -f
+: Removing path outside the testscript working directory succeeds with -f
: option. Need to use a path that unlikely exists (not to remove something
: useful).
:
diff --git a/tests/test/script/integration/testscript b/tests/test/script/integration/testscript
index 8960b88..7cd8f0a 100644
--- a/tests/test/script/integration/testscript
+++ b/tests/test/script/integration/testscript
@@ -8,6 +8,9 @@
.include ../../common.test
+cd = [string] $path.canonicalize(./)
+td = [string] $path.canonicalize(test/)
+
: scrip-files
:
{
@@ -15,18 +18,18 @@
: testscript-and-other
:
- $* <<EOI 2>>EOE != 0
+ $* <<EOI 2>>"EOE" != 0
./: test{../testscript ../foo}
EOI
- error: both 'testscript' and other names specified for dir{./}
+ error: both 'testscript' and other names specified for dir{$cd}
EOE
: other-and-testscript
:
- $* <<EOI 2>>EOE != 0
+ $* <<EOI 2>>"EOE" != 0
./: test{../foo ../testscript}
EOI
- error: both 'testscript' and other names specified for dir{./}
+ error: both 'testscript' and other names specified for dir{$cd}
EOE
: others
@@ -40,20 +43,20 @@
:
touch foo.test;
touch test;
-$* <<EOI 2>>EOE != 0
+$* <<EOI 2>>"EOE" != 0
./: test{foo}
EOI
-error: working directory test/ is a file/symlink
+error: working directory $td is a file/symlink
EOE
: wd-exists-before
:
touch foo.test;
mkdir test &!test/;
-$* <<EOI 2>>EOE
+$* <<EOI 2>>"EOE"
./: test{foo}
EOI
-warning: working directory test/ exists at the beginning of the test
+warning: working directory $td exists at the beginning of the test
EOE
: wd-not-empty-before
@@ -61,10 +64,10 @@ EOE
touch foo.test;
mkdir test &!test/;
touch test/dummy &!test/dummy;
-$* <<EOI 2>>EOE
+$* <<EOI 2>>"EOE"
./: test{foo}
EOI
-warning: working directory test/ exists and is not empty at the beginning of the test
+warning: working directory $td exists and is not empty at the beginning of the test
EOE
: wd-not-empty-after
@@ -78,8 +81,8 @@ EOE
cat <<EOI >>>foo.test;
touch ../../dummy
EOI
-$* <<EOI 2>>EOE &test/*** != 0
+$* <<EOI 2>>"EOE" &test/*** != 0
./: test{foo}
EOI
-error: working directory test/ is not empty at the end of the test
+error: working directory $td is not empty at the end of the test
EOE
diff --git a/tests/test/script/runner/cleanup.test b/tests/test/script/runner/cleanup.test
index 52c0a29..c68304c 100644
--- a/tests/test/script/runner/cleanup.test
+++ b/tests/test/script/runner/cleanup.test
@@ -6,6 +6,8 @@
b += --no-column
+td = [string] $path.canonicalize(test/)
+
# Valid cleanups.
#
# @@ TODO: $c <"$* -f a &a" && $b
@@ -27,7 +29,7 @@ $b
: file-implicit
:
-: Test that a file created out of the script working directory is not
+: Test that a file created out of the testscript working directory is not
: implicitly registered for cleanup. If it were, the test would fail due to
: 'rm' failure.
:
@@ -59,7 +61,7 @@ $b
: dir-implicit
:
-: Test that a directory created out of the script working directory is not
+: Test that a directory created out of the testscript working directory is not
: implicitly registered for cleanup. If it were, the test would fail due to
: 'rm' failure.
:
@@ -91,27 +93,27 @@ $b
: Test cleanup of non-existing file.
:
$c <"$* &a";
-$b 2>>EOE != 0
-testscript:1: error: registered for cleanup file test/1/a does not exist
+$b 2>>"EOE" != 0
+testscript:1: error: registered for cleanup file $path.canonicalize(test/1/a) does not exist
EOE
: file-out-wd
:
-: Test explicit cleanup of a file out of the script working directory.
+: Test explicit cleanup of a file out of the testscript working directory.
:
$c <"$* &../../a";
-$b 2>>EOE != 0
-testscript:1: error: file cleanup ../../a is out of working directory test/
+$b 2>>"EOE" != 0
+testscript:1: error: file cleanup $path.canonicalize(../../a) is out of working directory $td
EOE
: file-in-wd
:
-: Test cleanup explicit registration of a file being outside the scope working
+: Test cleanup explicit registration of a file being outside the test working
: directory but inside the script working directory.
:
$c <"$* &../a";
-$b 2>>EOE != 0
-testscript:1: error: registered for cleanup file test/a does not exist
+$b 2>>"EOE" != 0
+testscript:1: error: registered for cleanup file $path.canonicalize(test/a) does not exist
EOE
: not-file
@@ -126,27 +128,27 @@ $b 2>- != 0 # @@ REGEX
: Test cleanup of non-existing directory.
:
$c <"$* &a/";
-$b 2>>EOE != 0
-testscript:1: error: registered for cleanup directory test/1/a/ does not exist
+$b 2>>"EOE" != 0
+testscript:1: error: registered for cleanup directory ([string] $path.canonicalize(test/1/a/)) does not exist
EOE
: dir-out-wd
:
-: Test cleanup of a directory out of the script working directory.
+: Test cleanup of a directory out of the testscript working directory.
:
$c <"$* &../../a/";
-$b 2>>EOE != 0
-testscript:1: error: directory cleanup ../../a/ is out of working directory test/
+$b 2>>"EOE" != 0
+testscript:1: error: directory cleanup ([string] $path.canonicalize(../../a/)) is out of working directory $td
EOE
: dir-in-wd
:
-: Test cleanup explicit registration of a directory being outside the scope
-: working directory but inside the script working directory.
+: Test cleanup explicit registration of a directory being outside the test
+: working directory but inside the testscript working directory.
:
$c <"$* &../a/";
-$b 2>>EOE != 0
-testscript:1: error: registered for cleanup directory test/a/ does not exist
+$b 2>>"EOE" != 0
+testscript:1: error: registered for cleanup directory ([string] $path.canonicalize(test/a/)) does not exist
EOE
: dir-not-empty
@@ -154,8 +156,8 @@ EOE
: Test cleanup of a non-empty directory.
:
$c <"$* -d a -f a/b &a/";
-$b 2>>EOE != 0
-testscript:1: error: registered for cleanup directory test/1/a/ is not empty
+$b 2>>"EOE" != 0
+testscript:1: error: registered for cleanup directory ([string] $path.canonicalize(test/1/a/)) is not empty
EOE
: not-dir
@@ -170,27 +172,27 @@ $b 2>- != 0 # @@ REGEX
: Test cleanup of a wildcard not matching any directory.
:
$c <"$* &a/***";
-$b 2>>EOE != 0
-testscript:1: error: registered for cleanup wildcard test/1/a/*** doesn't match a directory
+$b 2>>"EOE" != 0
+testscript:1: error: registered for cleanup wildcard $path.canonicalize(test/1/a/***) doesn't match a directory
EOE
: wildcard-out-wd
:
-: Test cleanup of a wildcard out of the script working directory.
+: Test cleanup of a wildcard out of the testscript working directory.
:
$c <"$* &../../a/***";
-$b 2>>EOE != 0
-testscript:1: error: wildcard cleanup ../../a/*** is out of working directory test/
+$b 2>>"EOE" != 0
+testscript:1: error: wildcard cleanup $path.canonicalize(../../a/***) is out of working directory $td
EOE
: wildcard-in-wd
:
: Test cleanup registration of a wildcard matching the directory that being
-: outside the scope working directory is inside the script working directory.
+: outside the test working directory is inside the testscript working directory.
:
$c <"$* &../a/***";
-$b 2>>EOE != 0
-testscript:1: error: registered for cleanup wildcard test/a/*** doesn't match a directory
+$b 2>>"EOE" != 0
+testscript:1: error: registered for cleanup wildcard $path.canonicalize(test/a/***) doesn't match a directory
EOE
: wildcard-not-dir
@@ -205,8 +207,8 @@ $b 2>- != 0 # @@ REGEX
: Test an implicit cleanup being overwritten with the explicit one,
:
$c <"$* -o foo >>>a &!a";
-$b 2>>EOE != 0
-testscript:1: error: registered for cleanup directory test/1/ is not empty
+$b 2>>"EOE" != 0
+testscript:1: error: registered for cleanup directory ([string] $path.canonicalize(test/1/)) is not empty
EOE
: explicit-overwrite
@@ -217,6 +219,6 @@ $c <<"EOO";
$* &!a;
$* -o foo >>>a
EOO
-$b 2>>EOE != 0
-testscript:2: error: registered for cleanup directory test/1/ is not empty
+$b 2>>"EOE" != 0
+testscript:2: error: registered for cleanup directory ([string] $path.canonicalize(test/1/)) is not empty
EOE
diff --git a/tests/test/script/runner/status.test b/tests/test/script/runner/status.test
index f743518..941d485 100644
--- a/tests/test/script/runner/status.test
+++ b/tests/test/script/runner/status.test
@@ -28,12 +28,12 @@ $b
:
$c <"$* -s 1 == 0";
$b 2>>"EOE" != 0
-testscript:1: error: ../../../driver$ext exit status 1 != 0
+testscript:1: error: $path.canonicalize(../../../driver$ext) exit status 1 != 0
EOE
: ne-false
:
$c <"$* -s 1 != 1";
$b 2>>"EOE" != 0
-testscript:1: error: ../../../driver$ext exit status 1 == 1
+testscript:1: error: $path.canonicalize(../../../driver$ext) exit status 1 == 1
EOE
diff --git a/tests/value/reverse.test b/tests/value/reverse.test
index 2ebfe68..52c21e8 100644
--- a/tests/value/reverse.test
+++ b/tests/value/reverse.test
@@ -1,4 +1,4 @@
-# file : tests/directive/reverse.test
+# file : tests/value/reverse.test
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
@@ -46,17 +46,15 @@ EOO
: dir-path
:
-r = ([string] $path.canonicalize(foo/bar/));
-s = ([string] $path.canonicalize(foo/bar));
$* <<EOI >>"EOO"
x = [dir_path] foo/bar/
print ([string] $x)
print "$x"
print "-I$x"
EOI
-$r
-$s
--I$s
+foo/bar/
+foo/bar
+-Ifoo/bar
EOO
: dir-path-root