From ab0d6919707349436edd336bbfa8f433bd6e6749 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 9 Feb 2018 15:00:16 +0200 Subject: Fix broken test (and few other things) --- tests/test/simple/generated/buildfile | 4 +++- tests/test/simple/generated/driver.cxx | 25 +++++++++++++++++++++++-- tests/test/simple/generated/input.in | 1 + tests/test/simple/generated/testscript | 25 ++++++++++++++----------- tests/test/simple/generated/utility.cxx | 28 ---------------------------- 5 files changed, 41 insertions(+), 42 deletions(-) create mode 100644 tests/test/simple/generated/input.in delete mode 100644 tests/test/simple/generated/utility.cxx (limited to 'tests/test/simple/generated') diff --git a/tests/test/simple/generated/buildfile b/tests/test/simple/generated/buildfile index af97abd..2d795a8 100644 --- a/tests/test/simple/generated/buildfile +++ b/tests/test/simple/generated/buildfile @@ -5,4 +5,6 @@ # Test generated test inputs/outputs. # -./: test{testscript} $b file{*.cxx +*.in} +./: test{testscript} exe{driver} $b file{*.in} + +exe{driver}: cxx{driver} diff --git a/tests/test/simple/generated/driver.cxx b/tests/test/simple/generated/driver.cxx index fb3ab8f..a8e5cab 100644 --- a/tests/test/simple/generated/driver.cxx +++ b/tests/test/simple/generated/driver.cxx @@ -2,10 +2,31 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file +#include +#include #include +using namespace std; + int -main () +main (int argc, char* argv[]) { - std::cout << "1.2.3" << std::endl; + int r (0); + + if (argc == 1) + { + cout << "1.2.3" << endl; + } + else + { + ifstream ifs (argv[1]); + + if (!ifs.is_open ()) + cerr << "unable to open " << argv[1] << endl; + + string s; + r = getline (ifs, s) && s == "1.2.3" ? 0 : 1; + } + + return r; } diff --git a/tests/test/simple/generated/input.in b/tests/test/simple/generated/input.in new file mode 100644 index 0000000..36d79d4 --- /dev/null +++ b/tests/test/simple/generated/input.in @@ -0,0 +1 @@ +$version$ diff --git a/tests/test/simple/generated/testscript b/tests/test/simple/generated/testscript index 9ec5220..f7ab8d6 100644 --- a/tests/test/simple/generated/testscript +++ b/tests/test/simple/generated/testscript @@ -17,26 +17,29 @@ name: test version: 1.2.3 EOI -+cat <=build/root.build -using cxx -EOI +# This one is a bit tricky since we need an executable to run. We don't want +# to be building anything as part of our test project so what we do is test +# the directory target with an overridden test target (note that $src_root +# here refers to the root of the project being tested). : input : -ln -s $src_base/driver.cxx ./; -ln -s $src_base/utility.cxx ./; +ln -s $src_base/input.in ./; $* < -#include - -using namespace std; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " " << endl; - return 1; - } - - ifstream ifs (argv[1], ifstream::in | ifstream::binary | ifstream::ate); - - if (!ifs.is_open ()) - cerr << "unable to open " << argv[1] << endl; - - if (ifs.tellg () == 0) - cerr << argv[1] << " is empty" << endl; - - return 0; -} -- cgit v1.1