osb/source/test/game_tests_main.cpp
Kai Blaschke 431a9c00a5
Fixed a huge amount of Clang warnings
On Linux and macOS, using Clang to compile OpenStarbound produces about 400 MB worth of warnings during the build, making the compiler output unreadable and slowing the build down considerably.

99% of the warnings were unqualified uses of std::move and std::forward, which are now all properly qualified.

Fixed a few other minor warnings about non-virtual destructors and some uses of std::move preventing copy elision on temporary objects.

Most remaining warnings are now unused parameters.
2024-02-19 16:55:19 +01:00

44 lines
1.1 KiB
C++

#include "StarLogging.hpp"
#include "StarFile.hpp"
#include "StarRootLoader.hpp"
#include "gtest/gtest.h"
using namespace Star;
struct ErrorLogSink : public LogSink {
ErrorLogSink() {
setLevel(LogLevel::Error);
}
void log(char const* msg, LogLevel) override {
ADD_FAILURE() << "Error was logged: " << msg;
}
};
class TestEnvironment : public testing::Environment {
public:
unique_ptr<Root> root;
Root::Settings settings;
TestEnvironment(Root::Settings settings)
: settings(std::move(settings)) {}
virtual void SetUp() {
Logger::addSink(make_shared<ErrorLogSink>());
root = make_unique<Root>(settings);
root->configuration()->set("clearUniverseFiles", true);
root->configuration()->set("clearPlayerFiles", true);
}
virtual void TearDown() {
root.reset();
}
};
GTEST_API_ int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
testing::AddGlobalTestEnvironment(new TestEnvironment(RootLoader({{}, {}, {}, LogLevel::Error, true, {}}).commandParseOrDie(argc, argv).first));
return RUN_ALL_TESTS();
}