mirror of
https://github.com/Icinga/icinga2.git
synced 2026-02-18 18:19:13 -05:00
I've used the following command to replace the original copyright header
lines in a C-style comment block:
```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{/\*[^*]*\(\s*c\s*\)\s*(\d{4})\s*Icinga\s+GmbH[^*]*\*/}{// SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n// SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```
For files that use shell-style comments (#) like CMakeLists.txt, I've
used this command:
```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{#.*\(\s*c\s*\)\s(\d{4})\sIcinga\s+GmbH.*}{# SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n# SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```
And for SQL files:
```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{--.*\(c\)\s(\d{4})\sIcinga\sGmbH.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{-- Copyright \(c\)\s(\d{4})\sIcinga\s+Development\sTeam.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```
58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
// SPDX-FileCopyrightText: 2025 Icinga GmbH <https://icinga.com>
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <BoostTestTargetConfig.h>
|
|
#include <boost/filesystem/path.hpp>
|
|
#include <boost/test/tree/traverse.hpp>
|
|
#include <fstream>
|
|
|
|
namespace icinga {
|
|
|
|
/**
|
|
* A boost test decorator to set additional ctest properties for the test.
|
|
*/
|
|
class CTestProperties : public boost::unit_test::decorator::base
|
|
{
|
|
public:
|
|
explicit CTestProperties(std::string props) : m_Props(std::move(props)) {}
|
|
|
|
std::string m_Props;
|
|
|
|
private:
|
|
/**
|
|
* Doesn't do anything to the case/suite it's applied to.
|
|
*
|
|
* However this gets added to the list so we can later find it by iterating the
|
|
* decorators and dynamic_casting them to this type and get the m_props value.
|
|
*/
|
|
void apply(boost::unit_test::test_unit&) override {}
|
|
[[nodiscard]] boost::unit_test::decorator::base_ptr clone() const override;
|
|
};
|
|
|
|
class CTestFileGenerator : public boost::unit_test::test_tree_visitor
|
|
{
|
|
public:
|
|
CTestFileGenerator(const boost::filesystem::path& testexe, const boost::filesystem::path& outfile);
|
|
|
|
void visit(const boost::unit_test::test_case& test) override;
|
|
|
|
bool test_suite_start(const boost::unit_test::test_suite& suite) override;
|
|
void test_suite_finish(const boost::unit_test::test_suite& suite) override;
|
|
|
|
private:
|
|
static std::string LabelsToProp(const std::vector<std::string>& labels);
|
|
|
|
std::ofstream m_Fp;
|
|
boost::filesystem::path m_WorkDir;
|
|
boost::filesystem::path m_TestExe;
|
|
std::vector<std::vector<std::string>> m_PropsStack;
|
|
};
|
|
|
|
struct CTestFileGeneratorFixture
|
|
{
|
|
CTestFileGeneratorFixture();
|
|
};
|
|
|
|
} // namespace icinga
|