Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -14,6 +14,7 @@ import ( |
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 | 16 |
func buildTestBinary(t *testing.T, tmpdir string, prefix string) (string, string) {
|
| 17 |
+ t.Helper() |
|
| 17 | 18 |
tmpDir, err := ioutil.TempDir(tmpdir, prefix) |
| 18 | 19 |
assert.NilError(t, err) |
| 19 | 20 |
exePath := tmpDir + "/" + prefix |
| ... | ... |
@@ -41,24 +42,25 @@ func TestTrap(t *testing.T) {
|
| 41 | 41 |
defer os.RemoveAll(tmpDir) |
| 42 | 42 |
|
| 43 | 43 |
for _, v := range sigmap {
|
| 44 |
- cmd := exec.Command(exePath) |
|
| 45 |
- cmd.Env = append(os.Environ(), "SIGNAL_TYPE="+v.name) |
|
| 46 |
- if v.multiple {
|
|
| 47 |
- cmd.Env = append(cmd.Env, "IF_MULTIPLE=1") |
|
| 48 |
- } |
|
| 49 |
- err := cmd.Start() |
|
| 50 |
- assert.NilError(t, err) |
|
| 51 |
- err = cmd.Wait() |
|
| 52 |
- if e, ok := err.(*exec.ExitError); ok {
|
|
| 44 |
+ t.Run(v.name, func(t *testing.T) {
|
|
| 45 |
+ cmd := exec.Command(exePath) |
|
| 46 |
+ cmd.Env = append(os.Environ(), "SIGNAL_TYPE="+v.name) |
|
| 47 |
+ if v.multiple {
|
|
| 48 |
+ cmd.Env = append(cmd.Env, "IF_MULTIPLE=1") |
|
| 49 |
+ } |
|
| 50 |
+ err := cmd.Start() |
|
| 51 |
+ assert.NilError(t, err) |
|
| 52 |
+ err = cmd.Wait() |
|
| 53 |
+ e, ok := err.(*exec.ExitError) |
|
| 54 |
+ assert.Assert(t, ok, "expected exec.ExitError, got %T", e) |
|
| 55 |
+ |
|
| 53 | 56 |
code := e.Sys().(syscall.WaitStatus).ExitStatus() |
| 54 | 57 |
if v.multiple {
|
| 55 | 58 |
assert.Check(t, is.DeepEqual(128+int(v.signal.(syscall.Signal)), code)) |
| 56 | 59 |
} else {
|
| 57 | 60 |
assert.Check(t, is.Equal(99, code)) |
| 58 | 61 |
} |
| 59 |
- continue |
|
| 60 |
- } |
|
| 61 |
- t.Fatal("process didn't end with any error")
|
|
| 62 |
+ }) |
|
| 62 | 63 |
} |
| 63 | 64 |
|
| 64 | 65 |
} |