Merge pull request #99 from birth-software/std-lib-tests
Introduce std tests and disable clang libs
This commit is contained in:
commit
f0125f2141
@ -32,8 +32,8 @@ pub fn main() !void {
|
||||
const context = try Compilation.createContext(allocator);
|
||||
try Compilation.compileBuildExecutable(context, command_arguments);
|
||||
} else if (equal(u8, command, "clang") or equal(u8, command, "-cc1") or equal(u8, command, "-cc1as")) {
|
||||
const exit_code = try clangMain(allocator, arguments);
|
||||
std.process.exit(exit_code);
|
||||
// const exit_code = try clangMain(allocator, arguments);
|
||||
// std.process.exit(exit_code);
|
||||
} else if (equal(u8, command, "cc")) {
|
||||
// TODO: transform our arguments to Clang and invoke it
|
||||
todo();
|
||||
|
90
build.zig
90
build.zig
@ -106,9 +106,9 @@ pub fn build(b: *std.Build) !void {
|
||||
const cpp_files = .{
|
||||
"src/llvm/llvm.cpp",
|
||||
"src/llvm/lld.cpp",
|
||||
"src/llvm/clang_main.cpp",
|
||||
"src/llvm/clang_cc1.cpp",
|
||||
"src/llvm/clang_cc1as.cpp",
|
||||
// "src/llvm/clang_main.cpp",
|
||||
// "src/llvm/clang_cc1.cpp",
|
||||
// "src/llvm/clang_cc1as.cpp",
|
||||
};
|
||||
compiler.addCSourceFiles(.{
|
||||
.files = &cpp_files,
|
||||
@ -310,48 +310,48 @@ pub fn build(b: *std.Build) !void {
|
||||
zlib,
|
||||
"libz.a",
|
||||
// Clang
|
||||
"libclangAnalysis.a",
|
||||
"libclangAnalysisFlowSensitive.a",
|
||||
"libclangAnalysisFlowSensitiveModels.a",
|
||||
"libclangAPINotes.a",
|
||||
"libclangARCMigrate.a",
|
||||
"libclangAST.a",
|
||||
"libclangASTMatchers.a",
|
||||
"libclangBasic.a",
|
||||
"libclangCodeGen.a",
|
||||
"libclangCrossTU.a",
|
||||
"libclangDependencyScanning.a",
|
||||
"libclangDirectoryWatcher.a",
|
||||
"libclangDriver.a",
|
||||
"libclangDynamicASTMatchers.a",
|
||||
"libclangEdit.a",
|
||||
"libclangExtractAPI.a",
|
||||
"libclangFormat.a",
|
||||
"libclangFrontend.a",
|
||||
"libclangFrontendTool.a",
|
||||
"libclangHandleCXX.a",
|
||||
"libclangHandleLLVM.a",
|
||||
"libclangIndex.a",
|
||||
"libclangIndexSerialization.a",
|
||||
"libclangInterpreter.a",
|
||||
"libclangLex.a",
|
||||
"libclangParse.a",
|
||||
"libclangRewrite.a",
|
||||
"libclangRewriteFrontend.a",
|
||||
"libclangSema.a",
|
||||
"libclangSerialization.a",
|
||||
"libclangStaticAnalyzerCheckers.a",
|
||||
"libclangStaticAnalyzerCore.a",
|
||||
"libclangStaticAnalyzerFrontend.a",
|
||||
"libclangSupport.a",
|
||||
"libclangTooling.a",
|
||||
"libclangToolingASTDiff.a",
|
||||
"libclangToolingCore.a",
|
||||
"libclangToolingInclusions.a",
|
||||
"libclangToolingInclusionsStdlib.a",
|
||||
"libclangToolingRefactoring.a",
|
||||
"libclangToolingSyntax.a",
|
||||
"libclangTransformer.a",
|
||||
// "libclangAnalysis.a",
|
||||
// "libclangAnalysisFlowSensitive.a",
|
||||
// "libclangAnalysisFlowSensitiveModels.a",
|
||||
// "libclangAPINotes.a",
|
||||
// "libclangARCMigrate.a",
|
||||
// "libclangAST.a",
|
||||
// "libclangASTMatchers.a",
|
||||
// "libclangBasic.a",
|
||||
// "libclangCodeGen.a",
|
||||
// "libclangCrossTU.a",
|
||||
// "libclangDependencyScanning.a",
|
||||
// "libclangDirectoryWatcher.a",
|
||||
// "libclangDriver.a",
|
||||
// "libclangDynamicASTMatchers.a",
|
||||
// "libclangEdit.a",
|
||||
// "libclangExtractAPI.a",
|
||||
// "libclangFormat.a",
|
||||
// "libclangFrontend.a",
|
||||
// "libclangFrontendTool.a",
|
||||
// "libclangHandleCXX.a",
|
||||
// "libclangHandleLLVM.a",
|
||||
// "libclangIndex.a",
|
||||
// "libclangIndexSerialization.a",
|
||||
// "libclangInterpreter.a",
|
||||
// "libclangLex.a",
|
||||
// "libclangParse.a",
|
||||
// "libclangRewrite.a",
|
||||
// "libclangRewriteFrontend.a",
|
||||
// "libclangSema.a",
|
||||
// "libclangSerialization.a",
|
||||
// "libclangStaticAnalyzerCheckers.a",
|
||||
// "libclangStaticAnalyzerCore.a",
|
||||
// "libclangStaticAnalyzerFrontend.a",
|
||||
// "libclangSupport.a",
|
||||
// "libclangTooling.a",
|
||||
// "libclangToolingASTDiff.a",
|
||||
// "libclangToolingCore.a",
|
||||
// "libclangToolingInclusions.a",
|
||||
// "libclangToolingInclusionsStdlib.a",
|
||||
// "libclangToolingRefactoring.a",
|
||||
// "libclangToolingSyntax.a",
|
||||
// "libclangTransformer.a",
|
||||
};
|
||||
|
||||
for (llvm_libraries) |llvm_library| {
|
||||
|
@ -302,4 +302,54 @@ pub fn main() !void {
|
||||
.group_name = "TEST EXECUTABLE",
|
||||
.is_test = true,
|
||||
});
|
||||
|
||||
std.debug.print("std... ", .{});
|
||||
|
||||
const result = try std.ChildProcess.run(.{
|
||||
.allocator = allocator,
|
||||
.argv = &.{ "zig-out/bin/nat", "test", "-main_source_file", "lib/std/std.nat", "-name", "std" },
|
||||
});
|
||||
const compilation_result: TestError!bool = switch (result.term) {
|
||||
.Exited => |exit_code| if (exit_code == 0) true else error.abnormal_exit_code,
|
||||
.Signal => error.signaled,
|
||||
.Stopped => error.stopped,
|
||||
.Unknown => error.unknown,
|
||||
};
|
||||
|
||||
const compilation_success = compilation_result catch b: {
|
||||
break :b false;
|
||||
};
|
||||
|
||||
std.debug.print("[COMPILATION {s}] ", .{if (compilation_success) "\x1b[32mOK\x1b[0m" else "\x1b[31mFAILED\x1b[0m"});
|
||||
if (result.stdout.len > 0) {
|
||||
std.debug.print("STDOUT:\n\n{s}\n\n", .{result.stdout});
|
||||
}
|
||||
if (result.stderr.len > 0) {
|
||||
std.debug.print("STDERR:\n\n{s}\n\n", .{result.stderr});
|
||||
}
|
||||
|
||||
if (compilation_success) {
|
||||
const test_run = try std.ChildProcess.run(.{
|
||||
.allocator = allocator,
|
||||
// TODO: delete -main_source_file?
|
||||
.argv = &.{ "nat/std" },
|
||||
});
|
||||
const test_result: TestError!bool = switch (test_run.term) {
|
||||
.Exited => |exit_code| if (exit_code == 0) true else error.abnormal_exit_code,
|
||||
.Signal => error.signaled,
|
||||
.Stopped => error.stopped,
|
||||
.Unknown => error.unknown,
|
||||
};
|
||||
|
||||
const test_success = test_result catch b: {
|
||||
break :b false;
|
||||
};
|
||||
std.debug.print("[TEST {s}]\n", .{if (test_success) "\x1b[32mOK\x1b[0m" else "\x1b[31mFAILED\x1b[0m"});
|
||||
if (test_run.stdout.len > 0) {
|
||||
std.debug.print("STDOUT:\n\n{s}\n\n", .{test_run.stdout});
|
||||
}
|
||||
if (test_run.stderr.len > 0) {
|
||||
std.debug.print("STDERR:\n\n{s}\n\n", .{test_run.stderr});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user