Commit e48c901e authored by Imdad Sardharwalla's avatar Imdad Sardharwalla Committed by GitHub Enterprise
Browse files

Remove pImpl pattern from Completion class (#24)

Also run clang-format.
parent 2f0c9cc9
......@@ -18,15 +18,17 @@ INSECURE_INCLUDE_SECTION_BEGIN
INSECURE_INCLUDE_SECTION_END
#endif // __APPLE__
namespace Test {
namespace Checksum {
namespace Test
{
namespace Checksum
{
namespace
{
#ifdef __APPLE__
namespace fs = boost::filesystem;
#else // __APPLE__
#else // __APPLE__
namespace fs = std::filesystem;
#endif // __APPLE__
......@@ -38,8 +40,9 @@ const char* const NOT_HANDLED_EXCEPTION = "NotHandledException";
// Should be called only if the test has not terminated correctly (process exit
// has not been logged) and returns one of these 3 results:
// NOT_HANDLED_EXCEPTION (a crash)
// TIMEOUT (test has been terminated by the test system because it was taking too much time)
// UNKNOWN_EXCEPTION (we are not able to find the cause of test termination).
// TIMEOUT (test has been terminated by the test system because it was taking
// too much time) UNKNOWN_EXCEPTION (we are not able to find the cause of test
// termination).
const char* find_failure(const Path& _dir)
{
// There has been a crash or a time out. A test timeout has been logged in a
......@@ -60,13 +63,13 @@ const char* find_failure(const Path& _dir)
return UNKNOWN_EXCEPTION; // Impossible to find the test termination problem.
// test.log contains a list of failing tests in the following format:
/*
The following tests FAILED:
18 - synthetic/box_open_25.cc (SEGFAULT)
19 - synthetic/box_open_08.cc (Failed)
20 - ReCap/OilPump_prep.off (Timeout)
...
*/
/*
The following tests FAILED:
18 - synthetic/box_open_25.cc (SEGFAULT)
19 - synthetic/box_open_08.cc (Failed)
20 - ReCap/OilPump_prep.off (Timeout)
...
*/
// The following code looks for lines with a ")" at the line end and a "-"
// in the middle, extracts the test name, checks if it is the one we are
// processing and checks if the string inside () is Timeout to decide if it
......@@ -94,7 +97,7 @@ The following tests FAILED:
while (dir_it != _dir.end() && *dir_it != *test_path_it)
++dir_it;
while (dir_it != _dir.end() && test_path_it != test_dir.end() &&
*dir_it == *test_path_it)
*dir_it == *test_path_it)
{
++dir_it;
++test_path_it;
......@@ -113,27 +116,16 @@ The following tests FAILED:
} // namespace
class Completion::Impl
Completion::Completion()
: Object("Completion", L_STABLE),
start_time_(std::chrono::system_clock::now())
{
public:
Impl()
{
start_time_ = std::chrono::system_clock::now();
}
std::chrono::time_point<std::chrono::system_clock> start_time_;
};
Completion::Completion() : Object("Completion", L_STABLE), impl_(new Impl) {}
Completion::~Completion()
{
delete impl_;
}
void Completion::record_end()
{
auto end_time = std::chrono::system_clock::now();
std::chrono::duration<double> time_diff_sec = end_time - impl_->start_time_;
std::chrono::duration<double> time_diff_sec = end_time - start_time_;
std::stringstream mess;
mess << "Success: " << END << " Time: " << time_diff_sec.count();
......@@ -151,14 +143,13 @@ Result Completion::report_failure(const Path& _dir, std::string& _descr)
bool Completion::end(const std::string& _line)
{
return _line.find(Checksum::completion.name()) != std::string::npos &&
_line.find(END) != std::string::npos;
_line.find(END) != std::string::npos;
}
// Register the checksum to check test completion.
Completion completion;
}//Checksum
}//Test
#endif//TEST_ON
} // namespace Checksum
} // namespace Test
#endif // TEST_ON
......@@ -8,17 +8,19 @@
#include <Base/Security/Mandatory.hh>
#include <Base/Test/TestChecksum.hh>
#include <chrono>
#include <string>
namespace Test {
namespace Checksum {
namespace Test
{
namespace Checksum
{
// Checks it the test has completed and, if not, detect the problem for compare.
class Completion : public Object
{
public:
Completion();
~Completion();
//! Record the test "end" completion checksum
void record_end();
......@@ -34,16 +36,14 @@ public:
static Result report_failure(const Path& _dir, std::string& _descr);
private:
class Impl;
Impl* impl_;
std::chrono::time_point<std::chrono::system_clock> start_time_;
};
// Register the checksum to check test completion.
extern Completion completion;
}//Checksum
}//Test
#endif//TEST_ON
#endif//BASE_CHECKSUMCOMPLETION_HH_INCLUDE
} // namespace Checksum
} // namespace Test
#endif // TEST_ON
#endif // BASE_CHECKSUMCOMPLETION_HH_INCLUDE
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