#include #include "test/test.h" #include "test/tester.h" #include "compile/compilation.h" #include "support/filesystem.h" namespace clice::testing { namespace { TEST_SUITE(Compiler) { TEST_CASE(TopLevelDecls) { Tester tester; llvm::StringRef content = R"( #include int x = 1; void foo {} namespace foo2 { int y = 2; int z = 3; } struct Bar { int x; int y; }; )"; tester.add_main("main.cpp", content); ASSERT_TRUE(tester.compile_with_pch()); ASSERT_EQ(tester.unit->top_level_decls().size(), 4U); } TEST_CASE(StopCompilation) { std::shared_ptr stop = std::make_shared(false); Tester tester; tester.params.stop = stop; llvm::StringRef content = R"( #include #include #include #include #include #include )"; tester.add_main("main.cpp", content); bool result = true; std::thread thread([&]() { result = tester.compile_with_pch(); }); std::this_thread::sleep_for(std::chrono::milliseconds(200)); stop->store(true); thread.join(); ASSERT_FALSE(result); } }; // TEST_SUITE(Compiler) } // namespace } // namespace clice::testing