Introduce std tests and disable clang libs
This commit is contained in:
parent
53f492918e
commit
cd7ab8455a
@ -32,8 +32,8 @@ pub fn main() !void {
|
|||||||
const context = try Compilation.createContext(allocator);
|
const context = try Compilation.createContext(allocator);
|
||||||
try Compilation.compileBuildExecutable(context, command_arguments);
|
try Compilation.compileBuildExecutable(context, command_arguments);
|
||||||
} else if (equal(u8, command, "clang") or equal(u8, command, "-cc1") or equal(u8, command, "-cc1as")) {
|
} else if (equal(u8, command, "clang") or equal(u8, command, "-cc1") or equal(u8, command, "-cc1as")) {
|
||||||
const exit_code = try clangMain(allocator, arguments);
|
// const exit_code = try clangMain(allocator, arguments);
|
||||||
std.process.exit(exit_code);
|
// std.process.exit(exit_code);
|
||||||
} else if (equal(u8, command, "cc")) {
|
} else if (equal(u8, command, "cc")) {
|
||||||
// TODO: transform our arguments to Clang and invoke it
|
// TODO: transform our arguments to Clang and invoke it
|
||||||
todo();
|
todo();
|
||||||
|
90
build.zig
90
build.zig
@ -106,9 +106,9 @@ pub fn build(b: *std.Build) !void {
|
|||||||
const cpp_files = .{
|
const cpp_files = .{
|
||||||
"src/llvm/llvm.cpp",
|
"src/llvm/llvm.cpp",
|
||||||
"src/llvm/lld.cpp",
|
"src/llvm/lld.cpp",
|
||||||
"src/llvm/clang_main.cpp",
|
// "src/llvm/clang_main.cpp",
|
||||||
"src/llvm/clang_cc1.cpp",
|
// "src/llvm/clang_cc1.cpp",
|
||||||
"src/llvm/clang_cc1as.cpp",
|
// "src/llvm/clang_cc1as.cpp",
|
||||||
};
|
};
|
||||||
compiler.addCSourceFiles(.{
|
compiler.addCSourceFiles(.{
|
||||||
.files = &cpp_files,
|
.files = &cpp_files,
|
||||||
@ -310,48 +310,48 @@ pub fn build(b: *std.Build) !void {
|
|||||||
zlib,
|
zlib,
|
||||||
"libz.a",
|
"libz.a",
|
||||||
// Clang
|
// Clang
|
||||||
"libclangAnalysis.a",
|
// "libclangAnalysis.a",
|
||||||
"libclangAnalysisFlowSensitive.a",
|
// "libclangAnalysisFlowSensitive.a",
|
||||||
"libclangAnalysisFlowSensitiveModels.a",
|
// "libclangAnalysisFlowSensitiveModels.a",
|
||||||
"libclangAPINotes.a",
|
// "libclangAPINotes.a",
|
||||||
"libclangARCMigrate.a",
|
// "libclangARCMigrate.a",
|
||||||
"libclangAST.a",
|
// "libclangAST.a",
|
||||||
"libclangASTMatchers.a",
|
// "libclangASTMatchers.a",
|
||||||
"libclangBasic.a",
|
// "libclangBasic.a",
|
||||||
"libclangCodeGen.a",
|
// "libclangCodeGen.a",
|
||||||
"libclangCrossTU.a",
|
// "libclangCrossTU.a",
|
||||||
"libclangDependencyScanning.a",
|
// "libclangDependencyScanning.a",
|
||||||
"libclangDirectoryWatcher.a",
|
// "libclangDirectoryWatcher.a",
|
||||||
"libclangDriver.a",
|
// "libclangDriver.a",
|
||||||
"libclangDynamicASTMatchers.a",
|
// "libclangDynamicASTMatchers.a",
|
||||||
"libclangEdit.a",
|
// "libclangEdit.a",
|
||||||
"libclangExtractAPI.a",
|
// "libclangExtractAPI.a",
|
||||||
"libclangFormat.a",
|
// "libclangFormat.a",
|
||||||
"libclangFrontend.a",
|
// "libclangFrontend.a",
|
||||||
"libclangFrontendTool.a",
|
// "libclangFrontendTool.a",
|
||||||
"libclangHandleCXX.a",
|
// "libclangHandleCXX.a",
|
||||||
"libclangHandleLLVM.a",
|
// "libclangHandleLLVM.a",
|
||||||
"libclangIndex.a",
|
// "libclangIndex.a",
|
||||||
"libclangIndexSerialization.a",
|
// "libclangIndexSerialization.a",
|
||||||
"libclangInterpreter.a",
|
// "libclangInterpreter.a",
|
||||||
"libclangLex.a",
|
// "libclangLex.a",
|
||||||
"libclangParse.a",
|
// "libclangParse.a",
|
||||||
"libclangRewrite.a",
|
// "libclangRewrite.a",
|
||||||
"libclangRewriteFrontend.a",
|
// "libclangRewriteFrontend.a",
|
||||||
"libclangSema.a",
|
// "libclangSema.a",
|
||||||
"libclangSerialization.a",
|
// "libclangSerialization.a",
|
||||||
"libclangStaticAnalyzerCheckers.a",
|
// "libclangStaticAnalyzerCheckers.a",
|
||||||
"libclangStaticAnalyzerCore.a",
|
// "libclangStaticAnalyzerCore.a",
|
||||||
"libclangStaticAnalyzerFrontend.a",
|
// "libclangStaticAnalyzerFrontend.a",
|
||||||
"libclangSupport.a",
|
// "libclangSupport.a",
|
||||||
"libclangTooling.a",
|
// "libclangTooling.a",
|
||||||
"libclangToolingASTDiff.a",
|
// "libclangToolingASTDiff.a",
|
||||||
"libclangToolingCore.a",
|
// "libclangToolingCore.a",
|
||||||
"libclangToolingInclusions.a",
|
// "libclangToolingInclusions.a",
|
||||||
"libclangToolingInclusionsStdlib.a",
|
// "libclangToolingInclusionsStdlib.a",
|
||||||
"libclangToolingRefactoring.a",
|
// "libclangToolingRefactoring.a",
|
||||||
"libclangToolingSyntax.a",
|
// "libclangToolingSyntax.a",
|
||||||
"libclangTransformer.a",
|
// "libclangTransformer.a",
|
||||||
};
|
};
|
||||||
|
|
||||||
for (llvm_libraries) |llvm_library| {
|
for (llvm_libraries) |llvm_library| {
|
||||||
|
@ -302,4 +302,54 @@ pub fn main() !void {
|
|||||||
.group_name = "TEST EXECUTABLE",
|
.group_name = "TEST EXECUTABLE",
|
||||||
.is_test = true,
|
.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