Skip to content

Commit ba25b32

Browse files
pkg/csource: remove include guards from reproducers
Drop all lines matching `#define [A-Z0-9_]*_H` from the reproducers
1 parent 7dc1cb3 commit ba25b32

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pkg/csource/csource.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,9 @@ func (ctx *context) postProcess(result []byte) []byte {
685685
result = regexp.MustCompile(`\t*exitf\((.*\n)*?.*\);\n`).ReplaceAll(result, []byte("\texit(1);\n"))
686686
result = regexp.MustCompile(`\t*fail(msg)?\((.*\n)*?.*\);\n`).ReplaceAll(result, []byte("\texit(1);\n"))
687687

688+
// Remove executor include guards.
689+
result = regexp.MustCompile(`#define\s+[A-Z0-9_]*_H\s*\n`).ReplaceAll(result, nil)
690+
688691
result = ctx.hoistIncludes(result)
689692
result = ctx.removeEmptyLines(result)
690693
return result

pkg/csource/csource_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ func testOne(t *testing.T, p *prog.Prog, opts Options) {
140140
t.Logf("opts: %+v\nprogram:\n%s", opts, p.Serialize())
141141
t.Fatalf("%v", err)
142142
}
143+
// Executor headers are embedded into the C source. Make sure there are no leftover include guards.
144+
if matches := regexp.MustCompile(`(?m)^#define\s+\S+_H\s*\n`).FindAllString(string(src), -1); len(matches) > 0 {
145+
t.Fatalf("source contains leftover include guards: %v\nopts: %+v\nprogram:\n%s",
146+
matches, opts, p.Serialize())
147+
}
143148
bin, err := Build(p.Target, src)
144149
if err != nil {
145150
if atomic.AddUint32(&failedTests, 1) > maxFailures {

0 commit comments

Comments
 (0)