(t *testing.T)
| 32 | } |
| 33 | |
| 34 | func TestBuildMSYS2Command_WithMsvcEnvs(t *testing.T) { |
| 35 | var displayCmd string |
| 36 | executor := NewExecutor("", "make -j 4").SetMsvcEnvs(`call "C:\VC\vcvarsall.bat" x64 > nul &&`) |
| 37 | cmd := executor.buildMSYS2Command(&displayCmd) |
| 38 | |
| 39 | if !strings.Contains(displayCmd, executor.msvcEnvs) { |
| 40 | t.Errorf("displayCmd should contain msvcEnvs, got: %s", displayCmd) |
| 41 | } |
| 42 | if !strings.Contains(displayCmd, executor.command) { |
| 43 | t.Errorf("displayCmd should contain command, got: %s", displayCmd) |
| 44 | } |
| 45 | if !strings.HasPrefix(displayCmd, executor.msvcEnvs) { |
| 46 | t.Errorf("msvcEnvs should be at the beginning of displayCmd, got: %s", displayCmd) |
| 47 | } |
| 48 | |
| 49 | if len(cmd.Args) < 3 { |
| 50 | t.Fatalf("expected at least 3 args for bash -lc, got: %v", cmd.Args) |
| 51 | } |
| 52 | if cmd.Args[0] != "bash" { |
| 53 | t.Errorf("expected first arg to be bash, got: %s", cmd.Args[0]) |
| 54 | } |
| 55 | if cmd.Args[1] != "-lc" { |
| 56 | t.Errorf("expected second arg to be -lc, got: %s", cmd.Args[1]) |
| 57 | } |
| 58 | combined := cmd.Args[2] |
| 59 | if !strings.Contains(combined, executor.msvcEnvs) { |
| 60 | t.Errorf("bash command should contain msvcEnvs, got: %s", combined) |
| 61 | } |
| 62 | if !strings.Contains(combined, executor.command) { |
| 63 | t.Errorf("bash command should contain command, got: %s", combined) |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | func TestBuildMSYS2Command_WithoutMsvcEnvs(t *testing.T) { |
| 68 | var displayCmd string |
nothing calls this directly
no test coverage detected