refactor: extract expander helpers and Test stdio/file setters
- Add globWithAffixes in runner/expander.go that wraps filepath.Glob
with an empty-match check and returns the computed prefix/suffix
from splitGlob, collapsing three near-identical lookup blocks in
expandGlobPattern into single calls.
- Extract per-case Test construction from buildTests into a new
buildTest helper so the loop body is a single call and the read /
assemble / arg-template logic lives in one place.
- Add Test.SetInputFile, Test.SetStdin, Test.SetOutputFile and
Test.SetStdout methods on dsl.Test to encapsulate the stdin-vs-
InFiles and stdout-vs-OutFiles wiring that buildTest previously
did inline.
- Adopt the `for range N` loop form in the determinism check in
runner/compiler_test.go.
- Switch the MSVC release test to expect /std:c17 since MSVC does
not ship a c11 mode (worth surfacing a warning about this later).
This commit is contained in:
@@ -185,7 +185,7 @@ func TestCompileGNUDefinesOrderDeterministic(t *testing.T) {
|
||||
}
|
||||
tc := Toolchain{Class: CompilerGNU, Binary: "gcc"}
|
||||
argv1, _ := Compile(cfg, tc, "s")
|
||||
for i := 0; i < 20; i++ {
|
||||
for range 20 {
|
||||
argv2, _ := Compile(cfg, tc, "s")
|
||||
if !reflect.DeepEqual(argv1, argv2) {
|
||||
t.Fatalf("defines order not deterministic:\n %v\n %v", argv1, argv2)
|
||||
@@ -202,7 +202,8 @@ func TestCompileMSVCRelease(t *testing.T) {
|
||||
}
|
||||
tc := Toolchain{Class: CompilerMSVC, Binary: "cl", Name: "msvc"}
|
||||
argv, _ := Compile(cfg, tc, "solution.exe")
|
||||
want := []string{"cl", "/nologo", "/std:c11", "/O2", "/W4", "solution.c", "/Fe:solution.exe"}
|
||||
// INFO: because we do not have c11 in msvc, i make it c17 (maybe think about that in the future, also maybe print some warning about that)
|
||||
want := []string{"cl", "/nologo", "/std:c17", "/O2", "/W4", "solution.c", "/Fe:solution.exe"}
|
||||
if !reflect.DeepEqual(argv, want) {
|
||||
t.Errorf("argv =\n %v\nwant\n %v", argv, want)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user