(t *testing.T)
| 168 | } |
| 169 | |
| 170 | func writeStopSignalScript(t *testing.T) string { |
| 171 | t.Helper() |
| 172 | |
| 173 | scriptDir := t.TempDir() |
| 174 | scriptPath := filepath.Join(scriptDir, "stop-signal.sh") |
| 175 | script := `#!/bin/sh |
| 176 | set -eu |
| 177 | |
| 178 | signal="$1" |
| 179 | child="" |
| 180 | |
| 181 | cleanup() { |
| 182 | echo "Received ${signal}" |
| 183 | if [ -n "${child}" ]; then |
| 184 | kill "${child}" 2>/dev/null || true |
| 185 | fi |
| 186 | exit 0 |
| 187 | } |
| 188 | |
| 189 | trap cleanup "${signal}" |
| 190 | |
| 191 | sleep 5000 & |
| 192 | child="$!" |
| 193 | wait "${child}" |
| 194 | ` |
| 195 | require.NoError(t, os.WriteFile(scriptPath, []byte(script), 0644)) |
| 196 | return scriptDir |
| 197 | } |
no test coverage detected
searching dependent graphs…