aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-10-01 15:01:39 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:33 +0200
commit88effd4a0d63e37a2851712f63a9709a1e322946 (patch)
tree8a6334a870f56afb5bf76c32d0bd202de694995c
parent69c7ec31219d666bba4f053fcce07d4df58b8ba2 (diff)
Fix sibs not finding test code in subdirs of test dir
Fix platform specific configs, not all configs were checked
-rw-r--r--backend/BackendUtils.cpp2
-rw-r--r--backend/ninja/Ninja.cpp4
-rw-r--r--include/Conf.hpp8
-rw-r--r--src/Conf.cpp2
-rw-r--r--tests/src/confTest/confTest.cpp4
5 files changed, 10 insertions, 10 deletions
diff --git a/backend/BackendUtils.cpp b/backend/BackendUtils.cpp
index 4e1a0e8..92a73ef 100644
--- a/backend/BackendUtils.cpp
+++ b/backend/BackendUtils.cpp
@@ -104,7 +104,7 @@ namespace backend
projectConfPath += TINYDIR_STRING("project.conf");
auto projectConfFileType = getFileType(projectConfPath.c_str());
- if(projectConfFileType == FileType::REGULAR)
+ if(!sibsConfig.isTest() && getFileType(projectConfPath.c_str()) == FileType::REGULAR)
{
backend::Ninja *subProject = new backend::Ninja();
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp
index 0c9cf0e..666bba7 100644
--- a/backend/ninja/Ninja.cpp
+++ b/backend/ninja/Ninja.cpp
@@ -1485,7 +1485,7 @@ namespace backend
bool zigTest = false;
if(config.zigTestAllFiles)
{
- backend::BackendUtils::collectSourceFiles(testSourceDirNative.c_str(), &ninja, sibsTestConfig, false);
+ backend::BackendUtils::collectSourceFiles(testSourceDirNative.c_str(), &ninja, sibsTestConfig);
// TODO: This can be optimized as well. No need to insert non-zig files if we are going to remove them.
// Maybe pass a filter callback function to @collectSourceFiles.
for(auto it = ninja.sourceFiles.begin(); it != ninja.sourceFiles.end(); )
@@ -1512,7 +1512,7 @@ namespace backend
}
else
{
- backend::BackendUtils::collectSourceFiles(testSourceDirNative.c_str(), &ninja, sibsTestConfig, false);
+ backend::BackendUtils::collectSourceFiles(testSourceDirNative.c_str(), &ninja, sibsTestConfig);
}
if(!ninja.getSourceFiles().empty())
diff --git a/include/Conf.hpp b/include/Conf.hpp
index d492e99..87f4fad 100644
--- a/include/Conf.hpp
+++ b/include/Conf.hpp
@@ -191,8 +191,8 @@ namespace sibs
"config.openbsd64.static.debug",
"config.openbsd64.static.release"
};
- const int NUM_CONFIGS = 12;
- const int CONFIGS_GENERIC_OFFSET = 15;
+ const int NUM_CONFIGS = 3 * 13;
+ const int CONFIGS_GENERIC_OFFSET = 3 * 5;
#if OS_TYPE == OS_TYPE_WINDOWS
#ifdef SIBS_ENV_32BIT
@@ -490,7 +490,7 @@ namespace sibs
virtual bool define(const std::string &name, const std::string &value);
virtual const std::unordered_map<std::string, std::string>& getDefines() const;
- virtual bool isTest() { return false; }
+ virtual bool isTest() const { return false; }
// Get define value by name.
// Return empty string if the value is empty or if the defined value doesn't exist
@@ -558,7 +558,7 @@ namespace sibs
virtual ~SibsTestConfig(){}
- bool isTest() override { return true; }
+ bool isTest() const override { return true; }
PackageType getPackageType() const override
{
diff --git a/src/Conf.cpp b/src/Conf.cpp
index c93f830..090e1e1 100644
--- a/src/Conf.cpp
+++ b/src/Conf.cpp
@@ -461,7 +461,7 @@ namespace sibs
// Do not free file content (fileContentResult) on purpose, since we are using the data and sibs is short lived
Result<bool> parseResult = Parser::parse(code, config);
if(!parseResult)
- return Result<bool>::Err("Failed to read config for: " + parseResult.getErrMsg());
+ return Result<bool>::Err("Failed to read config, reason: " + parseResult.getErrMsg());
if(!config.isTest())
{
diff --git a/tests/src/confTest/confTest.cpp b/tests/src/confTest/confTest.cpp
index 100c7cf..b5d5ae1 100644
--- a/tests/src/confTest/confTest.cpp
+++ b/tests/src/confTest/confTest.cpp
@@ -61,7 +61,7 @@ TEST_CASE("parse config - invalid object")
SibsConfig sibsConfig(Compiler::GCC, TINYDIR_STRING("tests/src/confTest"), OPT_LEV_DEBUG, false);
Result<bool> result = Config::readFromFile(TINYDIR_STRING("tests/src/confTest/invalidObject.conf"), sibsConfig);
REQUIRE(result.isErr());
- REQUIRE(result.getErrMsg() == "Invalid config object \"invalidObj\"");
+ REQUIRE(result.getErrMsg().find("Invalid config object \"invalidObj\"") != std::string::npos);
}
TEST_CASE("parse config - invalid field")
@@ -69,7 +69,7 @@ TEST_CASE("parse config - invalid field")
SibsConfig sibsConfig(Compiler::GCC, TINYDIR_STRING("tests/src/confTest"), OPT_LEV_DEBUG, false);
Result<bool> result = Config::readFromFile(TINYDIR_STRING("tests/src/confTest/invalidField.conf"), sibsConfig);
REQUIRE(result.isErr());
- REQUIRE(result.getErrMsg() == "Invalid field \"invalidField\" under object \"package\"");
+ REQUIRE(result.getErrMsg().find("Invalid field \"invalidField\" under object \"package\"") != std::string::npos);
}
TEST_CASE("parse config - use different config for different platforms")