From 5a36f357e174d002722122d2408c57fb43da6e59 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 21 Apr 2017 09:17:01 +0200 Subject: Implement execution of Windows batch files --- tests/process/driver.cxx | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'tests/process/driver.cxx') diff --git a/tests/process/driver.cxx b/tests/process/driver.cxx index fc9ffe9..ae5015c 100644 --- a/tests/process/driver.cxx +++ b/tests/process/driver.cxx @@ -143,10 +143,11 @@ exec (const path& p, } catch (const process_error& e) { + //cerr << args[0] << ": " << e << endl; + if (e.child) exit (1); - //cerr << args[0] << ": " << e << endl; return false; } } @@ -176,6 +177,7 @@ main (int argc, const char* argv[]) for (; i != argc; ++i) { string v (argv[i]); + if (v == "-c") child = true; else if (v == "-b") @@ -254,6 +256,8 @@ main (int argc, const char* argv[]) return 0; } + dir_path owd (dir_path::current_directory ()); + // Test processes created as "already terminated". // { @@ -309,7 +313,7 @@ main (int argc, const char* argv[]) assert (exec (dir_path (".") / fp.leaf ())); - // Fail for unexistent file path. + // Fail for non-existent file path. // assert (!exec (dir_path (".") / path ("dr"))); @@ -343,4 +347,21 @@ main (int argc, const char* argv[]) pr.handle = reinterpret_cast (-1); assert (!pr.wait (true) && !pr.wait (false)); #endif + + // Test execution of Windows batch files. The test file is in the original + // working directory. + // +#ifdef _WIN32 + { + assert (exec (owd / "test.bat")); + assert (exec (owd / "test")); + + paths = owd.string () + path::traits::path_separator + paths; + assert (_putenv (("PATH=" + paths).c_str ()) == 0); + + assert (exec (path ("test.bat"))); + assert (exec (path ("test"))); + assert (!exec (path ("testX.bat"))); + } +#endif } -- cgit v1.1