Commit c4723359 authored by Martin Marinov's avatar Martin Marinov Committed by GitHub Enterprise
Browse files

REFORM-1006 Support multiple tests per file in Test::Paths (#30)

* Add the option to supply test id when instantiating Test Paths to support files with multiple tests
* Return absolute path from Test::Paths::input_filename_path()
* Fix warnings picked up in the Linux build
parent c6bafcdc
......@@ -67,7 +67,7 @@ Difference Object::compare_data(const String& _old, const String& _new) const
String diff;
diff.resize((std::max(_old.length(), _new.length())));
for (int i = 0; i < diff.size(); ++i)
for (size_t i = 0; i < diff.size(); ++i)
{
diff[i] = i < _old.length() && i < _new.length() && _old[i] == _new[i] ?
' ' : '*';
......@@ -146,6 +146,8 @@ Difference Object::compare(
default: ; // disable warnings
};
break;
case Result::TYPE_NUMBER:
; // make compilers happy
}
return data_diff;
}
......
......@@ -88,7 +88,7 @@ void Paths::wait_for_debug_attach()
#endif // TEST_WAIT_FOR_DEBUG_ATTACH
void Paths::init(const char* const _in_root, const char* const _in_rel_path,
const char* const _out_root)
const char* const _out_root, const char* const _test_id)
{
fs::path in_root(_in_root);
fs::path in_rel_path(_in_rel_path);
......@@ -102,7 +102,9 @@ void Paths::init(const char* const _in_root, const char* const _in_rel_path,
// test output directory, and switch to it
if (_out_root != nullptr)
{
const auto out_dir = fs::path(_out_root) / in_rel_path;
auto out_dir = fs::path(_out_root) / in_rel_path;
if (_test_id != nullptr)
out_dir /= _test_id;
make_directory(out_dir);
fs::current_path(out_dir); // set output as current path
}
......@@ -113,13 +115,13 @@ void Paths::init(const char* const _in_root, const char* const _in_rel_path,
}
Paths::Paths(const char* const _in_root, const char* const _in_rel_path,
const char* const _out_root)
const char* const _out_root, const char* const _test_id)
{
#ifdef TEST_WAIT_FOR_DEBUG_ATTACH
wait_for_debug_attach();
#endif // TEST_WAIT_FOR_DEBUG_ATTACH
init(_in_root, _in_rel_path, _out_root);
init(_in_root, _in_rel_path, _out_root, _test_id);
}
Paths::Paths(
......@@ -160,7 +162,7 @@ std::string Paths::input_filename_path(const char* const _flnm) const
{
fs::path inpt_flnm_path(input_directory());
inpt_flnm_path /= _flnm;
return inpt_flnm_path.string();
return fs::absolute(inpt_flnm_path).string();
}
} // namespace Test
......
......@@ -43,9 +43,10 @@ public:
output folder is created, and the test output is stored within the current
working directory.
*/
Paths(const char* const _in_root, //!< input root directory
const char* const _in_rel_path, //!< input relative file path
const char* const _out_root = nullptr //!< output root directory
Paths(const char* const _in_root, //!< input root directory
const char* const _in_rel_path, //!< input relative file path
const char* const _out_root = nullptr, //!< output root directory
const char* const _test_id = nullptr //!< test id (if multi-test file)
);
Paths(const int _argc, //!< number of executable arguments
......@@ -69,10 +70,11 @@ public:
std::string input_filename_path(const char* const _flnm) const;
private:
// Initialisation function for the class, called by the constructor
void init(const char* const _in_root, //!< input root directory
const char* const _in_rel_path, //!< input relative file path
const char* const _out_root = nullptr //!< output root directory
// Initialization function for the class, called by the constructor
void init(const char* const _in_root, //!< input root directory
const char* const _in_rel_path, //!< input relative file path
const char* const _out_root = nullptr, //!< output root directory
const char* const _test_id = nullptr //!< test id (if multi-test file)
);
#ifdef TEST_WAIT_FOR_DEBUG_ATTACH
......
......@@ -168,7 +168,7 @@ void TestList::collect_tests(const Test::Path& _dir, const size_t _root_path_siz
// Compute the relative test path removing a number of subdirectory equal
// to the number of sub-directories in the root directory.
auto path_it = _dir.begin();
for (int sub_dir_nmbr = 0; path_it != _dir.end(); ++path_it)
for (size_t sub_dir_nmbr = 0; path_it != _dir.end(); ++path_it)
{
if (sub_dir_nmbr > _root_path_size)
rel_test_path /= *path_it;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment