-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This introduces ignition::common::testing, a component to hold all of our testing support functionality. Signed-off-by: Michael Carroll <[email protected]>
- Loading branch information
Showing
24 changed files
with
1,135 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ign_install_all_headers(COMPONENT testing) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2022 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
#ifndef IGNITION_COMMON_TESTING_AUTOLOGFIXTURE_HH_ | ||
#define IGNITION_COMMON_TESTING_AUTOLOGFIXTURE_HH_ | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include <ignition/utils/ImplPtr.hh> | ||
|
||
namespace ignition::common::testing | ||
{ | ||
/// \brief A utility class that stores test logs in ~/.ignition/test_logs. | ||
/// This functionality is needed to keep all the log information reported | ||
/// by ignition during continuous integration. Without this, debugging | ||
/// failing tests is significantly more difficult. | ||
class AutoLogFixture : public ::testing::Test | ||
{ | ||
/// \brief Constructor | ||
public: AutoLogFixture(); | ||
|
||
/// \brief Destructor | ||
public: virtual ~AutoLogFixture(); | ||
|
||
/// \brief Setup the test fixture. This gets called by gtest. | ||
protected: virtual void SetUp() override; | ||
|
||
/// \brief Get a string with the full log file path. | ||
/// \return The full log file path as a string. | ||
protected: std::string FullLogPath() const; | ||
|
||
/// \brief Get a string with all the log content loaded from the disk. | ||
/// \return A string with all the log content. | ||
protected: std::string LogContent() const; | ||
|
||
/// \brief Pointer to private data. | ||
IGN_UTILS_UNIQUE_IMPL_PTR(dataPtr) | ||
}; | ||
} // namespace ignition::common::testing | ||
|
||
#include <ignition/common/testing/detail/AutoLogFixture.hh> | ||
|
||
#endif // IGNITION_COMMON_TESTING_AUTOLOGFIXTURE_HH_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (C) 2022 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
#ifndef IGNITION_COMMON_TESTING_BAZELTESTPATHS_HH_ | ||
#define IGNITION_COMMON_TESTING_BAZELTESTPATHS_HH_ | ||
|
||
#include <string> | ||
|
||
#include "ignition/common/testing/TestPaths.hh" | ||
#include "ignition/common/testing/Export.hh" | ||
|
||
namespace ignition::common::testing | ||
{ | ||
|
||
/// \brief Implementation of TestPaths interface for Bazel | ||
/// | ||
/// It is not intended that users will directly construct this, but rather | ||
/// utilize the TestPathFactory. | ||
/// | ||
/// The main mechanism for detecting a bazel build is via the presence of the | ||
/// TEST_SRCDIR and TEST_UNDECLARED_OUTPUTS_DIR environment variables. | ||
/// Additionally, tests built via ign-bazel should set IGN_BAZEL_DIR. | ||
/// | ||
/// For source files to be available for bazel builds, they need to be set in | ||
/// the "data" section of the relevant cc_library or cc_test call. | ||
class BazelTestPaths: public TestPaths | ||
{ | ||
/// \brief Constructor from TestPaths | ||
public: using TestPaths::TestPaths; | ||
|
||
/// \brief Destructor | ||
public: IGNITION_COMMON_TESTING_VISIBLE ~BazelTestPaths() override; | ||
|
||
/// Documentation inherited | ||
public: bool IGNITION_COMMON_TESTING_VISIBLE | ||
ProjectSourcePath(std::string &_sourceDir) override; | ||
|
||
/// Documentation inherited | ||
public: bool IGNITION_COMMON_TESTING_VISIBLE | ||
TestTmpPath(std::string &_tmpDir) override; | ||
}; | ||
|
||
} // namespace ignition::common::testing | ||
|
||
#endif // IGNITION_COMMON_TESTING_AUTOLOGFIXTURE_HH_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (C) 2022 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
#ifndef IGNITION_COMMON_TESTING_CMAKETESTPATHS_HH_ | ||
#define IGNITION_COMMON_TESTING_CMAKETESTPATHS_HH_ | ||
|
||
#include <string> | ||
|
||
#include "ignition/common/testing/TestPaths.hh" | ||
#include "ignition/common/testing/Export.hh" | ||
|
||
namespace ignition::common::testing | ||
{ | ||
/// \brief Implementation of TestPaths interface for CMake | ||
/// | ||
/// It is not intended that users will directly construct this, but rather | ||
/// utilize the TestPathFactory. | ||
class CMakeTestPaths: public TestPaths | ||
{ | ||
/// \brief Constructor from TestPaths | ||
public: using TestPaths::TestPaths; | ||
|
||
/// \brief Destructor | ||
public: IGNITION_COMMON_TESTING_VISIBLE ~CMakeTestPaths() override; | ||
|
||
/// Documentation inherited | ||
public: bool IGNITION_COMMON_TESTING_VISIBLE | ||
ProjectSourcePath(std::string &_sourceDir) override; | ||
|
||
/// Documentation inherited | ||
public: bool IGNITION_COMMON_TESTING_VISIBLE | ||
TestTmpPath(std::string &_tmpDir) override; | ||
}; | ||
} // namespace ignition::common::testing | ||
#endif // IGNITION_COMMON_TESTING_CMAKETESTPATHS_HH_ |
Oops, something went wrong.