From 375c7c9770c5407af33058170d13d9801a508b30 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 17 Aug 2019 20:35:59 +0300 Subject: Don't load default options from directories which subdirectory contains --no-default-options --- tests/default-options/driver.cxx | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'tests/default-options/driver.cxx') diff --git a/tests/default-options/driver.cxx b/tests/default-options/driver.cxx index 535df31..106f70f 100644 --- a/tests/default-options/driver.cxx +++ b/tests/default-options/driver.cxx @@ -45,7 +45,9 @@ using namespace butl; // Default options file name. Can be specified multiple times. // // -d -// Directory to start the default options files search from. +// Directory to start the default options files search from. Can be +// specified multiple times, in which case a common start (parent) +// directory is deduced. // // -s // System directory. @@ -59,6 +61,9 @@ using namespace butl; // // ,, // +// -t +// Trace the default options files search to STDERR. +// int main (int argc, const char* argv[]) { @@ -94,6 +99,9 @@ main (int argc, const char* argv[]) bool r (false); while (optional o = s.next ()) { + if (*o == "--no-default-options") + no_default_options_ = true; + push_back (move (*o)); r = true; } @@ -105,6 +113,15 @@ main (int argc, const char* argv[]) { insert (end (), o.begin (), o.end ()); } + + bool + no_default_options () const noexcept + { + return no_default_options_; + } + + private: + bool no_default_options_ = false; }; // Parse and validate the arguments. @@ -112,8 +129,10 @@ main (int argc, const char* argv[]) default_options_files fs; optional sys_dir; optional home_dir; + vector dirs; options cmd_ops; bool print_entries (false); + bool trace (false); for (int i (1); i != argc; ++i) { @@ -127,7 +146,7 @@ main (int argc, const char* argv[]) else if (op == "-d") { assert (++i != argc); - fs.start_dir = dir_path (argv[i]); + dirs.emplace_back (argv[i]); } else if (op == "-s") { @@ -143,10 +162,18 @@ main (int argc, const char* argv[]) { print_entries = true; } + else if (op == "-t") + { + trace = true; + } else cmd_ops.push_back (argv[i]); } + // Deduce a common start directory. + // + fs.start = default_options_start (home_dir, dirs); + // Load and print the default options. // default_options def_ops ( @@ -154,7 +181,12 @@ main (int argc, const char* argv[]) sys_dir, home_dir, fs, - [] (const path&, bool) {})); + [trace] (const path& f, bool remote, bool overwrite) + { + if (trace) + cerr << (overwrite ? "overwriting " : "loading ") + << (remote ? "remote " : "local ") << f << endl; + })); if (print_entries) { -- cgit v1.1