diff options
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLib/testGccDepfileReader.cxx | 21 | ||||
-rw-r--r-- | Tests/CMakeLib/testGccDepfileReader_data/deps4.d | 1 | ||||
-rw-r--r-- | Tests/CMakeLib/testGccDepfileReader_data/deps5.d | 0 | ||||
-rw-r--r-- | Tests/CMakeLib/testGccDepfileReader_data/deps5.txt | 2 | ||||
-rw-r--r-- | Tests/CMakeLib/testGccDepfileReader_data/deps7.d | 6 | ||||
-rw-r--r-- | Tests/CMakeLib/testGccDepfileReader_data/deps7.txt | 10 |
6 files changed, 35 insertions, 5 deletions
diff --git a/Tests/CMakeLib/testGccDepfileReader.cxx b/Tests/CMakeLib/testGccDepfileReader.cxx index e79f047..d46e8f3 100644 --- a/Tests/CMakeLib/testGccDepfileReader.cxx +++ b/Tests/CMakeLib/testGccDepfileReader.cxx @@ -5,6 +5,8 @@ #include <utility> #include <vector> +#include <cm/optional> + #include "cmsys/FStream.hxx" #include "cmGccDepfileReader.h" @@ -112,17 +114,26 @@ int testGccDepfileReader(int argc, char* argv[]) std::string dataDirPath = argv[1]; dataDirPath += "/testGccDepfileReader_data"; - const int numberOfTestFiles = 3; + const int numberOfTestFiles = 7; // 6th file doesn't exist for (int i = 1; i <= numberOfTestFiles; ++i) { const std::string base = dataDirPath + "/deps" + std::to_string(i); const std::string depfile = base + ".d"; const std::string plainDepfile = base + ".txt"; std::cout << "Comparing " << base << " with " << plainDepfile << std::endl; const auto actual = cmReadGccDepfile(depfile.c_str()); - const auto expected = readPlainDepfile(plainDepfile.c_str()); - if (!compare(actual, expected)) { - dump("actual", actual); - dump("expected", expected); + if (cmSystemTools::FileExists(plainDepfile)) { + if (!actual) { + std::cerr << "Reading " << depfile << " should have succeeded\n"; + return 1; + } + const auto expected = readPlainDepfile(plainDepfile.c_str()); + if (!compare(*actual, expected)) { + dump("actual", *actual); + dump("expected", expected); + return 1; + } + } else if (actual) { + std::cerr << "Reading " << depfile << " should have failed\n"; return 1; } } diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps4.d b/Tests/CMakeLib/testGccDepfileReader_data/deps4.d new file mode 100644 index 0000000..9977a28 --- /dev/null +++ b/Tests/CMakeLib/testGccDepfileReader_data/deps4.d @@ -0,0 +1 @@ +invalid diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps5.d b/Tests/CMakeLib/testGccDepfileReader_data/deps5.d new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/CMakeLib/testGccDepfileReader_data/deps5.d diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps5.txt b/Tests/CMakeLib/testGccDepfileReader_data/deps5.txt new file mode 100644 index 0000000..6c4a75b --- /dev/null +++ b/Tests/CMakeLib/testGccDepfileReader_data/deps5.txt @@ -0,0 +1,2 @@ +--RULES-- +--DEPENDENCIES-- diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps7.d b/Tests/CMakeLib/testGccDepfileReader_data/deps7.d new file mode 100644 index 0000000..92280cf --- /dev/null +++ b/Tests/CMakeLib/testGccDepfileReader_data/deps7.d @@ -0,0 +1,6 @@ +out1 \ + out2: \ + in1 \ + in2 + +out3: in3 diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps7.txt b/Tests/CMakeLib/testGccDepfileReader_data/deps7.txt new file mode 100644 index 0000000..86b6600 --- /dev/null +++ b/Tests/CMakeLib/testGccDepfileReader_data/deps7.txt @@ -0,0 +1,10 @@ +--RULES-- +out1 +out2 +--DEPENDENCIES-- +in1 +in2 +--RULES-- +out3 +--DEPENDENCIES-- +in3 |