#include #include "Test/Tester.h" #include "Compiler/Compilation.h" #include "Support/FileSystem.h" namespace clice::testing { namespace { suite<"Compiler"> compiler = [] { test("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); expect(that % tester.compile_with_pch() == true); expect(that % tester.unit->top_level_decls().size() == 4); }; test("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(); expect(that % !result); }; }; } // namespace } // namespace clice::testing