diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2016-10-28 00:50:02 +0300 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-11-04 09:26:36 +0200 |
commit | 18235d8e5f37c0e65b5f1e3cacb6e3d27c3e05eb (patch) | |
tree | 7f41d442210d6159be2853a663af989ff58cc424 | |
parent | b3e6cb1b899dcc6b3488f10d8eee437a6f87ad15 (diff) |
Add support of paths cleanups to testscript runner
-rw-r--r-- | build2/test/script/runner.cxx | 9 | ||||
-rw-r--r-- | tests/test/script/runner/buildfile | 4 | ||||
-rw-r--r-- | tests/test/script/runner/cleanup.test | 10 | ||||
-rw-r--r-- | tests/test/script/runner/driver.cxx | 15 |
4 files changed, 37 insertions, 1 deletions
diff --git a/build2/test/script/runner.cxx b/build2/test/script/runner.cxx index 79cbfc4..23a4a5c 100644 --- a/build2/test/script/runner.cxx +++ b/build2/test/script/runner.cxx @@ -189,6 +189,10 @@ namespace build2 // // Note that we operate with normalized paths here. // + // @@ What if to make cleanup insensitive to the registration order, + // and sorting paths properly prior removal? Would it produce any + // testing flaws? + // set<path> rp; for (auto& p: reverse_iterate (sp.cleanups)) { @@ -414,6 +418,11 @@ namespace build2 // pr.wait (); + // Register command-created paths for cleanup. + // + for (const auto& p: c.cleanups) + sp.cleanups.emplace_back (normalize (p)); + // If there is no correct exit status by whatever reason then dump // stderr (if cached), print the proper diagnostics and fail. // diff --git a/tests/test/script/runner/buildfile b/tests/test/script/runner/buildfile index ddab8a5..e5f2761 100644 --- a/tests/test/script/runner/buildfile +++ b/tests/test/script/runner/buildfile @@ -2,6 +2,8 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -exe{driver}: cxx{driver} test{redirect status} +import libs = libbutl%lib{butl} + +exe{driver}: cxx{driver} $libs test{cleanup redirect status} include ../../../../../build2/ diff --git a/tests/test/script/runner/cleanup.test b/tests/test/script/runner/cleanup.test new file mode 100644 index 0000000..76cff63 --- /dev/null +++ b/tests/test/script/runner/cleanup.test @@ -0,0 +1,10 @@ +# file : tests/test/script/runner/cleanup.test +# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +$* -f a &a # file +$* -d a &a/ # dir1 +$* -d a/b &a/ &a/b/ # dir2 +$* -d a/b -f a/b/c &a/ &a/b/ &a/b/c # file-dir +$* -f a &a &a # file-dup +$* -d a/b &a/ &a/b/ &a/b/../b/ # dir-dup diff --git a/tests/test/script/runner/driver.cxx b/tests/test/script/runner/driver.cxx index fdada73..10d5857 100644 --- a/tests/test/script/runner/driver.cxx +++ b/tests/test/script/runner/driver.cxx @@ -10,12 +10,18 @@ #include <iostream> #include <exception> +#include <butl/path> +#include <butl/fdstream> +#include <butl/filesystem> + using namespace std; +using namespace butl; int main (int argc, char* argv[]) { // Usage: driver [-i <int>] [-s <int>] (-o <string>)* (-e <string>)* + // (-f <file>)* (-d <dir>)* // int status (256); int ifd (3); @@ -72,6 +78,15 @@ main (int argc, char* argv[]) status = toi (v); assert (status >= 0 && status < 256); } + else if (o == "-f") + { + ofdstream os (v); + os.close (); + } + else if (o == "-d") + { + try_mkdir_p (dir_path (v)); + } else assert (false); } |