Add unit test

This commit is contained in:
Bartosz Polaczyk
2022-02-26 18:37:56 +01:00
parent 253e9597bd
commit a2067f8dfe
@@ -332,11 +332,27 @@ class TemplateBasedCCWrapperBuilderTests: FileXCTestCase {
XCTAssertNotEqual(newFileOutputData, Data())
}
func testPCHCompilationFallbacks() throws {
// Marker is empty to mimic the new file scenario
let pchFile = directory.appendingPathComponent("input.pch")
createValidPCCFile(pchFile)
arguments = ["-x", "objective-c-header", "-MF", dependencyFile.path, "-o", outputFile.path, pchFile.path]
try shellExec(Self.xccc.path, args: arguments, inDir: directory.path)
XCTAssertTrue(fileManager.fileExists(atPath: outputFile.path))
}
/// Creates a simple C code in the location
private func createValidCFile(_ location: URL) {
fileManager.createFile(atPath: location.path, contents: "int main(){}".data(using: .utf8), attributes: nil)
}
/// Creates a simple PCH code in the location
private func createValidPCCFile(_ location: URL) {
fileManager.createFile(atPath: location.path, contents: "#import <Availability.h>".data(using: .utf8), attributes: nil)
}
/// Creates a C code that requires extra CUSTOM_STR clang macro to compile
private func createInvalidCFile(_ location: URL) {
fileManager.createFile(