From 61d9e8699687342c2e32c32c8d4eb71760d5d290 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 26 Jun 2021 17:33:24 +0200 Subject: Use fork/exec instead of popen. Add Path class --- tests/src/confTest/confTest.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/src/confTest/confTest.cpp b/tests/src/confTest/confTest.cpp index 68e2225..c770266 100644 --- a/tests/src/confTest/confTest.cpp +++ b/tests/src/confTest/confTest.cpp @@ -3,6 +3,16 @@ using namespace sibs; +static FileString arg_list_to_string(const std::vector &args) { + FileString result; + for(const FileString &arg : args) { + if(!result.empty()) + result += TINYDIR_STRING(" "); + result += TINYDIR_STRING("\"") + arg + TINYDIR_STRING("\""); + } + return result; +} + TEST_CASE("parse config") { SibsConfig sibsConfig(Compiler::GCC, TINYDIR_STRING("tests/src/confTest"), OPT_LEV_DEBUG, false); @@ -20,28 +30,28 @@ TEST_CASE("parse config") REQUIRE(containsPlatform(sibsConfig.getPlatforms(), PLATFORM_WIN64)); REQUIRE(sibsConfig.getPackageListDependencies().size() == 2); - for(auto *dep : sibsConfig.getPackageListDependencies()) + for(const auto &dep : sibsConfig.getPackageListDependencies()) { - REQUIRE(dep->getSource() == Dependency::Source::PACKAGE_LIST); + REQUIRE(dep.getSource() == Dependency::Source::PACKAGE_LIST); } - auto *xxhashDependency = sibsConfig.getPackageListDependencies()[0]->asPackageListDependency(); + auto *xxhashDependency = sibsConfig.getPackageListDependencies()[0].asPackageListDependency(); REQUIRE(xxhashDependency->name == "xxhash"); REQUIRE(xxhashDependency->version.toString() == ">=0.1.0 and <1.0.0"); - const auto &catch2Dependency = sibsConfig.getPackageListDependencies()[1]->asPackageListDependency(); + const auto &catch2Dependency = sibsConfig.getPackageListDependencies()[1].asPackageListDependency(); REQUIRE(catch2Dependency->name == "catch2"); REQUIRE(catch2Dependency->version.toString() == ">=1.0.0 and <2.0.0"); REQUIRE(sibsConfig.shouldUseCmake()); REQUIRE(sibsConfig.getCmakeDir() == TINYDIR_STRING("tests/src/confTest/cmakeGlobal")); - REQUIRE(sibsConfig.getCmakeArgs() == "-G Ninja \"-DCMAKE_BUILD_TYPE=Debug\" \"-DENTITYX_RUN_BENCHMARKS=0\""); + REQUIRE(arg_list_to_string(sibsConfig.getCmakeArgs()) == "\"-G\" \"Ninja\" \"-DCMAKE_BUILD_TYPE=Debug\" \"-DENTITYX_RUN_BENCHMARKS=0\""); REQUIRE(sibsConfig.getCmakeDirStatic() == TINYDIR_STRING("tests/src/confTest/cmakeStatic")); - REQUIRE(sibsConfig.getCmakeArgsStatic() == "-G Ninja \"-DCMAKE_BUILD_TYPE=Debug\" \"-DENTITYX_RUN_BENCHMARKS=0\" \"-DENTITYX_BUILD_TESTING=0\""); + REQUIRE(arg_list_to_string(sibsConfig.getCmakeArgsStatic()) == "\"-G\" \"Ninja\" \"-DCMAKE_BUILD_TYPE=Debug\" \"-DENTITYX_RUN_BENCHMARKS=0\" \"-DENTITYX_BUILD_TESTING=0\""); REQUIRE(sibsConfig.getCmakeDirDynamic() == TINYDIR_STRING("tests/src/confTest/cmakeDynamic")); - REQUIRE(sibsConfig.getCmakeArgsDynamic() == "-G Ninja \"-DCMAKE_BUILD_TYPE=Debug\" \"-DENTITYX_RUN_BENCHMARKS=0\" \"-DENTITYX_BUILD_TESTING=0\" \"-DENTITYX_BUILD_SHARED=1\""); + REQUIRE(arg_list_to_string(sibsConfig.getCmakeArgsDynamic()) == "\"-G\" \"Ninja\" \"-DCMAKE_BUILD_TYPE=Debug\" \"-DENTITYX_RUN_BENCHMARKS=0\" \"-DENTITYX_BUILD_TESTING=0\" \"-DENTITYX_BUILD_SHARED=1\""); } TEST_CASE("parse config - invalid object") -- cgit v1.2.3