aboutsummaryrefslogtreecommitdiff
path: root/tests/default-options/testscript
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-09-10 19:05:23 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-09-11 19:09:24 +0300
commit377cec303eea81fb18b294eb47a54587643dbd01 (patch)
tree8437bff2e99415b49f22bbd325aa47c768716d7f /tests/default-options/testscript
parent2b14f09675c10d999779858ae31934b7eef55b89 (diff)
Add support for arguments in default options files helpers
Diffstat (limited to 'tests/default-options/testscript')
-rw-r--r--tests/default-options/testscript253
1 files changed, 147 insertions, 106 deletions
diff --git a/tests/default-options/testscript b/tests/default-options/testscript
index fa65e62..b168ca9 100644
--- a/tests/default-options/testscript
+++ b/tests/default-options/testscript
@@ -4,9 +4,9 @@
# Note that when cross-testing the driver may not be able to run the command
# due to the meaningless program path.
#
-+if ($test.target != $build.host)
- exit
-end
+#+if ($test.target != $build.host)
+# exit
+#end
: basic
:
@@ -14,46 +14,46 @@ end
sys_dir = $canonicalize([dir_path] $~/build2)
+mkdir -p $sys_dir/local
- +echo 'sys-foo' >=$sys_dir/foo
- +echo 'sys-bar' >=$sys_dir/bar
- +echo 'sys-local-foo' >=$sys_dir/local/foo
- +echo 'sys-local-bar' >=$sys_dir/local/bar
+ +echo '--sys-foo' >=$sys_dir/foo
+ +echo '--sys-bar' >=$sys_dir/bar
+ +echo '--sys-local-foo' >=$sys_dir/local/foo
+ +echo '--sys-local-bar' >=$sys_dir/local/bar
home_dir = $canonicalize([dir_path] $~/home)
+mkdir -p $home_dir/.build2/local/
- +echo 'home-foo' >=$home_dir/.build2/foo
- +echo 'home-bar' >=$home_dir/.build2/bar
- +echo 'home-local-foo' >=$home_dir/.build2/local/foo
- +echo 'home-local-bar' >=$home_dir/.build2/local/bar
+ +echo '--home-foo' >=$home_dir/.build2/foo
+ +echo '--home-bar' >=$home_dir/.build2/bar
+ +echo '--home-local-foo' >=$home_dir/.build2/local/foo
+ +echo '--home-local-bar' >=$home_dir/.build2/local/bar
work_dir = $home_dir/work
+mkdir -p $work_dir/.build2/local/
d = $work_dir/.build2
- +echo 'work-foo' >=$d/foo
- +echo 'work-bar' >=$d/bar
- +echo 'work-local-foo' >=$d/local/foo
- +echo 'work-local-bar' >=$d/local/bar
+ +echo '--work-foo' >=$d/foo
+ +echo '--work-bar' >=$d/bar
+ +echo '--work-local-foo' >=$d/local/foo
+ +echo '--work-local-bar' >=$d/local/bar
d = $work_dir/project/.build2
+mkdir -p $d/local/
+touch $work_dir/project/.git
- +echo 'project-foo' >=$d/foo
- +echo 'project-bar' >=$d/bar
- +echo 'project-local-foo' >=$d/local/foo
- +echo 'project-local-bar' >=$d/local/bar
+ +echo '--project-foo' >=$d/foo
+ +echo '--project-bar' >=$d/bar
+ +echo '--project-local-foo' >=$d/local/foo
+ +echo '--project-local-bar' >=$d/local/bar
d = $work_dir/project/package/.build2
+mkdir -p $d/local/
- +echo 'package-foo' >=$d/foo
- +echo 'package-bar' >=$d/bar
- +echo 'package-local-foo' >=$d/local/foo
- +echo 'package-local-bar' >=$d/local/bar
+ +echo '--package-foo' >=$d/foo
+ +echo '--package-bar' >=$d/bar
+ +echo '--package-local-foo' >=$d/local/foo
+ +echo '--package-local-bar' >=$d/local/bar
+echo '--no-default-options' >=$d/local/baz
@@ -62,26 +62,26 @@ end
: entries
:
$* -e -t -f foo -f bar -d $start_dir -s $sys_dir -h $home_dir >>/~%EOO%d 2>>/~%EOE%d
- %\.+/build2/foo,sys-foo,false%
- %\.+/build2/bar,sys-bar,false%
- %\.+/build2/local/foo,sys-local-foo,false%
- %\.+/build2/local/bar,sys-local-bar,false%
- %\.+/home/.build2/foo,home-foo,false%
- %\.+/home/.build2/bar,home-bar,false%
- %\.+/home/.build2/local/foo,home-local-foo,false%
- %\.+/home/.build2/local/bar,home-local-bar,false%
- %\.+/home/work/.build2/foo,work-foo,false%
- %\.+/home/work/.build2/bar,work-bar,false%
- %\.+/home/work/.build2/local/foo,work-local-foo,false%
- %\.+/home/work/.build2/local/bar,work-local-bar,false%
- %\.+/home/work/project/.build2/foo,project-foo,true%
- %\.+/home/work/project/.build2/bar,project-bar,true%
- %\.+/home/work/project/.build2/local/foo,project-local-foo,true%
- %\.+/home/work/project/.build2/local/bar,project-local-bar,true%
- %\.+/home/work/project/package/.build2/foo,package-foo,true%
- %\.+/home/work/project/package/.build2/bar,package-bar,true%
- %\.+/home/work/project/package/.build2/local/foo,package-local-foo,true%
- %\.+/home/work/project/package/.build2/local/bar,package-local-bar,true%
+ %\.+/build2/foo,--sys-foo,false%
+ %\.+/build2/bar,--sys-bar,false%
+ %\.+/build2/local/foo,--sys-local-foo,false%
+ %\.+/build2/local/bar,--sys-local-bar,false%
+ %\.+/home/.build2/foo,--home-foo,false%
+ %\.+/home/.build2/bar,--home-bar,false%
+ %\.+/home/.build2/local/foo,--home-local-foo,false%
+ %\.+/home/.build2/local/bar,--home-local-bar,false%
+ %\.+/home/work/.build2/foo,--work-foo,false%
+ %\.+/home/work/.build2/bar,--work-bar,false%
+ %\.+/home/work/.build2/local/foo,--work-local-foo,false%
+ %\.+/home/work/.build2/local/bar,--work-local-bar,false%
+ %\.+/home/work/project/.build2/foo,--project-foo,true%
+ %\.+/home/work/project/.build2/bar,--project-bar,true%
+ %\.+/home/work/project/.build2/local/foo,--project-local-foo,true%
+ %\.+/home/work/project/.build2/local/bar,--project-local-bar,true%
+ %\.+/home/work/project/package/.build2/foo,--package-foo,true%
+ %\.+/home/work/project/package/.build2/bar,--package-bar,true%
+ %\.+/home/work/project/package/.build2/local/foo,--package-local-foo,true%
+ %\.+/home/work/project/package/.build2/local/bar,--package-local-bar,true%
EOO
%loading local \.+/home/work/project/package/.build2/local/bar%
%loading local \.+/home/work/project/package/.build2/local/foo%
@@ -111,37 +111,37 @@ end
: merged
:
- $* -f foo -f bar -d $start_dir -s $sys_dir -h $home_dir cmd-foo cmd-bar >>EOO
- sys-foo
- sys-bar
- sys-local-foo
- sys-local-bar
- home-foo
- home-bar
- home-local-foo
- home-local-bar
- work-foo
- work-bar
- work-local-foo
- work-local-bar
- project-foo
- project-bar
- project-local-foo
- project-local-bar
- package-foo
- package-bar
- package-local-foo
- package-local-bar
- cmd-foo
- cmd-bar
+ $* -f foo -f bar -d $start_dir -s $sys_dir -h $home_dir --cmd-foo --cmd-bar >>EOO
+ --sys-foo
+ --sys-bar
+ --sys-local-foo
+ --sys-local-bar
+ --home-foo
+ --home-bar
+ --home-local-foo
+ --home-local-bar
+ --work-foo
+ --work-bar
+ --work-local-foo
+ --work-local-bar
+ --project-foo
+ --project-bar
+ --project-local-foo
+ --project-local-bar
+ --package-foo
+ --package-bar
+ --package-local-foo
+ --package-local-bar
+ --cmd-foo
+ --cmd-bar
EOO
: no-default-options
:
$* -e -t -f foo -f baz -f bar -d $start_dir -s $sys_dir -h $home_dir >>/~%EOO%d 2>>/~%EOE%d
- %\.+/home/work/project/package/.build2/local/foo,package-local-foo,true%
+ %\.+/home/work/project/package/.build2/local/foo,--package-local-foo,true%
%\.+/home/work/project/package/.build2/local/baz,--no-default-options,true%
- %\.+/home/work/project/package/.build2/local/bar,package-local-bar,true%
+ %\.+/home/work/project/package/.build2/local/bar,--package-local-bar,true%
EOO
%loading local \.+/home/work/project/package/.build2/local/bar%
%loading local \.+/home/work/project/package/.build2/local/baz%
@@ -152,6 +152,47 @@ end
EOE
}
+: args
+:
+{
+ home_dir = $canonicalize([dir_path] $~/home)
+ +mkdir -p $home_dir/.build2
+ +echo '--home' >=$home_dir/.build2/ops
+ +echo 'home' >+$home_dir/.build2/ops
+
+ start_dir = $canonicalize([dir_path] $home_dir/start)
+ +mkdir -p $start_dir/.build2
+ +echo '--start1' >=$start_dir/.build2/ops
+ +echo 'start2' >+$start_dir/.build2/ops
+ +echo '--start3' >+$start_dir/.build2/ops
+ +echo 'start4' >+$start_dir/.build2/ops
+
+ : allowed
+ :
+ $* -a -e -f ops -d $start_dir -h $home_dir >>/~%EOO%d
+ %\.+/home/.build2/ops,--home\|home,false%
+ %\.+/home/start/.build2/ops,--start1 --start3\|start2 start4,false%
+ EOO
+
+ : disallowed
+ :
+ $* -e -f ops -d $start_dir -h $home_dir 2>>EOE != 0
+ error: unexpected argument 'start2'
+ EOE
+
+ : merged
+ :
+ $* -a -f ops -d $start_dir -h $home_dir cmd >>EOO
+ --home
+ --start1
+ --start3
+ home
+ start2
+ start4
+ cmd
+ EOO
+}
+
: common-start
:
{
@@ -166,10 +207,10 @@ end
+mkdir -p $work_dir/.build2 $cfg1/.build2 $cfg2/.build2 $cfg3/.build2
- +echo 'work' >=$work_dir/.build2/ops
- +echo 'cfg1' >=$cfg1/.build2/ops
- +echo 'cfg2' >=$cfg2/.build2/ops
- +echo 'cfg3' >=$cfg3/.build2/ops
+ +echo '--work' >=$work_dir/.build2/ops
+ +echo '--cfg1' >=$cfg1/.build2/ops
+ +echo '--cfg2' >=$cfg2/.build2/ops
+ +echo '--cfg3' >=$cfg3/.build2/ops
: exists
:
@@ -177,29 +218,29 @@ end
: single
:
$* -f ops -d $cfg3 -h $home_dir >>EOO
- work
- cfg2
- cfg3
+ --work
+ --cfg2
+ --cfg3
EOO
: same
:
$* -f ops -d $cfg1 -d $cfg1 -h $home_dir >>EOO
- work
- cfg1
+ --work
+ --cfg1
EOO
: adjacent
:
$* -f ops -d $cfg1 -d $cfg2 -h $home_dir >>EOO
- work
+ --work
EOO
: nested
:
$* -f ops -d $cfg2 -d $cfg3 -h $home_dir >>EOO
- work
- cfg2
+ --work
+ --cfg2
EOO
}
@@ -209,7 +250,7 @@ end
: home-reached
:
$* -f ops -d $cfg1 -d $cfg2 -h $work_dir >>EOO
- work
+ --work
EOO
: root-reached
@@ -229,20 +270,20 @@ end
{
home_dir = $canonicalize([dir_path] $~/home);
mkdir -p $home_dir/.build2;
- echo 'home' >=$home_dir/.build2/ops;
+ echo '--home' >=$home_dir/.build2/ops;
extra_dir = $canonicalize([dir_path] $home_dir/extra);
mkdir -p $extra_dir;
- echo 'extra' >=$extra_dir/ops;
+ echo '--extra' >=$extra_dir/ops;
start_dir = $canonicalize([dir_path] $home_dir/start);
mkdir -p $start_dir/.build2;
- echo 'start' >=$start_dir/.build2/ops;
+ echo '--start' >=$start_dir/.build2/ops;
$* -e -f ops -d $start_dir -h $home_dir -x $extra_dir >>/~%EOO%d
- %\.+/home/.build2/ops,home,false%
- %\.+/home/extra/ops,extra,false%
- %\.+/home/start/.build2/ops,start,false%
+ %\.+/home/.build2/ops,--home,false%
+ %\.+/home/extra/ops,--extra,false%
+ %\.+/home/start/.build2/ops,--start,false%
EOO
}
@@ -251,56 +292,56 @@ end
{
home_dir = $canonicalize([dir_path] $~/home);
mkdir -p $home_dir/.build2;
- echo 'home' >=$home_dir/.build2/ops;
+ echo '--home' >=$home_dir/.build2/ops;
d = $home_dir/project/.build2;
mkdir -p $d;
- echo 'project' >=$d/ops;
+ echo '--project' >=$d/ops;
touch $home_dir/project/.git;
d = $home_dir/project/package/.build2;
mkdir -p $d;
- echo 'package' >=$d/ops;
+ echo '--package' >=$d/ops;
extra_dir = $canonicalize([dir_path] $home_dir/project/package/extra1);
mkdir -p $extra_dir;
- echo 'extra1' >=$extra_dir/ops;
+ echo '--extra1' >=$extra_dir/ops;
start_dir = $canonicalize([dir_path] $home_dir/project/package);
$* -e -f ops -d $start_dir -h $home_dir -x $extra_dir >>/~%EOO%d;
- %\.+/home/.build2/ops,home,false%
- %\.+/home/project/.build2/ops,project,true%
- %\.+/home/project/package/.build2/ops,package,true%
- %\.+/home/project/package/extra1/ops,extra1,false%
+ %\.+/home/.build2/ops,--home,false%
+ %\.+/home/project/.build2/ops,--project,true%
+ %\.+/home/project/package/.build2/ops,--package,true%
+ %\.+/home/project/package/extra1/ops,--extra1,false%
EOO
extra_dir = $canonicalize([dir_path] $home_dir/project/package/.build2);
$* -e -f ops -d $start_dir -h $home_dir -x $extra_dir/ >>/~%EOO%d;
- %\.+/home/.build2/ops,home,false%
- %\.+/home/project/.build2/ops,project,true%
- %\.+/home/project/package/.build2/ops,package,false%
+ %\.+/home/.build2/ops,--home,false%
+ %\.+/home/project/.build2/ops,--project,true%
+ %\.+/home/project/package/.build2/ops,--package,false%
EOO
extra_dir = $canonicalize([dir_path] $home_dir/project/extra2);
mkdir -p $extra_dir;
- echo 'extra2' >=$extra_dir/ops;
+ echo '--extra2' >=$extra_dir/ops;
$* -e -f ops -d $start_dir -h $home_dir -x $extra_dir >>/~%EOO%d;
- %\.+/home/.build2/ops,home,false%
- %\.+/home/project/.build2/ops,project,true%
- %\.+/home/project/extra2/ops,extra2,false%
- %\.+/home/project/package/.build2/ops,package,true%
+ %\.+/home/.build2/ops,--home,false%
+ %\.+/home/project/.build2/ops,--project,true%
+ %\.+/home/project/extra2/ops,--extra2,false%
+ %\.+/home/project/package/.build2/ops,--package,true%
EOO
extra_dir = $canonicalize([dir_path] $home_dir/project/.build2);
$* -e -f ops -d $start_dir -h $home_dir -x $extra_dir/ >>/~%EOO%d
- %\.+/home/.build2/ops,home,false%
- %\.+/home/project/.build2/ops,project,false%
- %\.+/home/project/package/.build2/ops,package,true%
+ %\.+/home/.build2/ops,--home,false%
+ %\.+/home/project/.build2/ops,--project,false%
+ %\.+/home/project/package/.build2/ops,--package,true%
EOO
}
}