From 20615c2161fb491e4c87b0cc8483c2e600ae6f79 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 21 Aug 2019 18:55:27 +0300 Subject: Add extra_dir parameter for load_default_options() --- tests/default-options/driver.cxx | 12 ++++- tests/default-options/testscript | 104 +++++++++++++++++++++++++++++++++++---- 2 files changed, 105 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/default-options/driver.cxx b/tests/default-options/driver.cxx index 106f70f..764ab44 100644 --- a/tests/default-options/driver.cxx +++ b/tests/default-options/driver.cxx @@ -35,7 +35,7 @@ using namespace std; using namespace butl; // Usage: argv[0] [-f ] [-d ] [-s ] [-h ] -// [-e] +// [-x ] [-e] [-t] // // Parse default options files, merge them with the command line options, and // print the resulting options to STDOUT one per line. Note that the options @@ -55,6 +55,9 @@ using namespace butl; // -h // Home directory. // +// -x +// Extra directory. +// // -e // Print the default options entries (rather than the merged options) to // STDOUT one per line in the following format: @@ -129,6 +132,7 @@ main (int argc, const char* argv[]) default_options_files fs; optional sys_dir; optional home_dir; + optional extra_dir; vector dirs; options cmd_ops; bool print_entries (false); @@ -158,6 +162,11 @@ main (int argc, const char* argv[]) assert (++i != argc); home_dir = dir_path (argv[i]); } + else if (op == "-x") + { + assert (++i != argc); + extra_dir = dir_path (argv[i]); + } else if (op == "-e") { print_entries = true; @@ -180,6 +189,7 @@ main (int argc, const char* argv[]) load_default_options ( sys_dir, home_dir, + extra_dir, fs, [trace] (const path& f, bool remote, bool overwrite) { diff --git a/tests/default-options/testscript b/tests/default-options/testscript index 89164d2..41badf3 100644 --- a/tests/default-options/testscript +++ b/tests/default-options/testscript @@ -167,17 +167,17 @@ end +mkdir -p $work_dir/.build2 $cfg1/.build2 $cfg2/.build2 $cfg3/.build2 - +echo 'work' >=$work_dir/.build2/cfg - +echo 'cfg1' >=$cfg1/.build2/cfg - +echo 'cfg2' >=$cfg2/.build2/cfg - +echo 'cfg3' >=$cfg3/.build2/cfg + +echo 'work' >=$work_dir/.build2/ops + +echo 'cfg1' >=$cfg1/.build2/ops + +echo 'cfg2' >=$cfg2/.build2/ops + +echo 'cfg3' >=$cfg3/.build2/ops : exists : { : single : - $* -f cfg -d $cfg3 -h $home_dir >>EOO + $* -f ops -d $cfg3 -h $home_dir >>EOO work cfg2 cfg3 @@ -185,20 +185,20 @@ end : same : - $* -f cfg -d $cfg1 -d $cfg1 -h $home_dir >>EOO + $* -f ops -d $cfg1 -d $cfg1 -h $home_dir >>EOO work cfg1 EOO : adjacent : - $* -f cfg -d $cfg1 -d $cfg2 -h $home_dir >>EOO + $* -f ops -d $cfg1 -d $cfg2 -h $home_dir >>EOO work EOO : nested : - $* -f cfg -d $cfg2 -d $cfg3 -h $home_dir >>EOO + $* -f ops -d $cfg2 -d $cfg3 -h $home_dir >>EOO work cfg2 EOO @@ -209,7 +209,7 @@ end { : home-reached : - $* -f cfg -d $cfg1 -d $cfg2 -h $work_dir >>EOO + $* -f ops -d $cfg1 -d $cfg2 -h $work_dir >>EOO work EOO @@ -217,7 +217,91 @@ end : if ($cxx.target.class != 'windows') { - $* -f cfg -d $cfg1 -d /non-existent-directory/cfg2 + $* -f ops -d $cfg1 -d /non-existent-directory/cfg2 } } } + +: extra-dir +: +{ + : after-traversal + : + { + home_dir = $canonicalize([dir_path] $~/home); + mkdir -p $home_dir/.build2; + echo 'home' >=$home_dir/.build2/ops; + + extra_dir = $canonicalize([dir_path] $home_dir/extra); + mkdir -p $extra_dir; + echo 'extra' >=$extra_dir/ops; + + start_dir = $canonicalize([dir_path] $home_dir/start); + mkdir -p $start_dir/.build2; + 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% + EOO + } + + : inside-traversal + : + { + home_dir = $canonicalize([dir_path] $~/home); + mkdir -p $home_dir/.build2; + echo 'home' >=$home_dir/.build2/ops; + + d = $home_dir/project/.build2; + mkdir -p $d; + echo 'project' >=$d/ops; + + touch $home_dir/project/.git; + + d = $home_dir/project/package/.build2; + mkdir -p $d; + echo 'package' >=$d/ops; + + extra_dir = $canonicalize([dir_path] $home_dir/project/package/extra1); + mkdir -p $extra_dir; + 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% + 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% + EOO + + extra_dir = $canonicalize([dir_path] $home_dir/project/extra2); + mkdir -p $extra_dir; + 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% + 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% + EOO + } +} -- cgit v1.1