Skip to content

Commit 5b5c8da

Browse files
committed
test: Allow cases to set emit_asm (defaults to false).
1 parent a29a434 commit 5b5c8da

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

test/src/Cases.zig

+10-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub const Case = struct {
6262
Header: []const u8,
6363
},
6464

65+
emit_asm: bool = false,
6566
emit_bin: bool = true,
6667
emit_h: bool = false,
6768
is_test: bool = false,
@@ -371,6 +372,7 @@ fn addFromDirInner(
371372
const output_mode = try manifest.getConfigForKeyAssertSingle("output_mode", std.builtin.OutputMode);
372373
const pic = try manifest.getConfigForKeyAssertSingle("pic", ?bool);
373374
const pie = try manifest.getConfigForKeyAssertSingle("pie", ?bool);
375+
const emit_asm = try manifest.getConfigForKeyAssertSingle("emit_asm", bool);
374376
const emit_bin = try manifest.getConfigForKeyAssertSingle("emit_bin", bool);
375377
const imports = try manifest.getConfigForKeyAlloc(ctx.arena, "imports", []const u8);
376378

@@ -438,6 +440,7 @@ fn addFromDirInner(
438440
.backend = backend,
439441
.files = .init(ctx.arena),
440442
.case = null,
443+
.emit_asm = emit_asm,
441444
.emit_bin = emit_bin,
442445
.is_test = is_test,
443446
.output_mode = output_mode,
@@ -663,7 +666,10 @@ pub fn lowerToBuildSteps(
663666

664667
switch (case.case.?) {
665668
.Compile => {
666-
// Force the binary to be emitted if requested.
669+
// Force the assembly/binary to be emitted if requested.
670+
if (case.emit_asm) {
671+
_ = artifact.getEmittedAsm();
672+
}
667673
if (case.emit_bin) {
668674
_ = artifact.getEmittedBin();
669675
}
@@ -761,6 +767,8 @@ const TestManifestConfigDefaults = struct {
761767
.run_translated_c => "Obj",
762768
.cli => @panic("TODO test harness for CLI tests"),
763769
};
770+
} else if (std.mem.eql(u8, key, "emit_asm")) {
771+
return "false";
764772
} else if (std.mem.eql(u8, key, "emit_bin")) {
765773
return "true";
766774
} else if (std.mem.eql(u8, key, "is_test")) {
@@ -802,6 +810,7 @@ const TestManifest = struct {
802810
trailing_bytes: []const u8 = "",
803811

804812
const valid_keys = std.StaticStringMap(void).initComptime(.{
813+
.{ "emit_asm", {} },
805814
.{ "emit_bin", {} },
806815
.{ "is_test", {} },
807816
.{ "output_mode", {} },

0 commit comments

Comments
 (0)