-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The test cases should be expanded, just a basic 'including windows.h doesn't explode' test for now
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const std = @import("std"); | ||
const build_options = @import("build_options"); | ||
const exe_path = build_options.cli_exe_path; | ||
|
||
test "including windows.h" { | ||
var tmp = std.testing.tmpDir(.{}); | ||
defer tmp.cleanup(); | ||
|
||
try tmp.dir.writeFile("test.rc", | ||
\\#include "windows.h" | ||
); | ||
|
||
try testExpectNoError(tmp.dir, &.{ exe_path, "test.rc" }); | ||
try testExpectNoError(tmp.dir, &.{ exe_path, "/:auto-includes", "gnu", "test.rc" }); | ||
} | ||
|
||
fn testExpectNoError(dir: std.fs.Dir, argv: []const []const u8) !void { | ||
const allocator = std.testing.allocator; | ||
|
||
const dir_path = try dir.realpathAlloc(allocator, "."); | ||
defer allocator.free(dir_path); | ||
|
||
const result = try std.ChildProcess.run(.{ | ||
.allocator = allocator, | ||
.argv = argv, | ||
.max_output_bytes = std.math.maxInt(u32), | ||
.cwd = dir_path, | ||
.cwd_dir = dir, | ||
}); | ||
defer allocator.free(result.stdout); | ||
defer allocator.free(result.stderr); | ||
|
||
if (result.term != .Exited or result.term.Exited != 0) { | ||
std.debug.print("command failed with unexpected errors:\n---\nstdout:\n---\n{s}\n---\nstderr:\n---\n{s}\n", .{ result.stdout, result.stderr }); | ||
return error.UnexpectedErrors; | ||
} | ||
} |