Skip to content

Commit a0ee557

Browse files
committed
Refactor testing functions for Alpine compatibility by consolidating checks for Busybox and removing redundant conditions in stage_q4.go and stage_q5.go.
1 parent f7772bf commit a0ee557

File tree

4 files changed

+4
-22
lines changed

4 files changed

+4
-22
lines changed

internal/stage7.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func testType2(stageHarness *test_case_harness.TestCaseHarness) error {
7070
expectedPath = filepath.Join(executableDir, myExeCommandName)
7171

7272
// Alpine Busybox has a bug where it doesn't check permissions
73-
if isTestingTesterUsingAshOnAlpine(stageHarness) {
73+
if isTestingTesterUsingBusyboxOnAlpine(stageHarness) {
7474
expectedPath = nonExePath
7575
}
7676
}

internal/stage_q4.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ func testQ4(stageHarness *test_case_harness.TestCaseHarness) error {
6262
fmt.Sprintf(`%s\\n%s`, L[4], L[1]),
6363
fileContents[0] + fileContents[1] + strings.TrimRight(fileContents[2], "\n"),
6464
}
65-
66-
if isTestingTesterUsingDashOnAlpine(stageHarness) {
67-
expectedOutputs[1] = fmt.Sprintf(`%s"%s%s"%s`, L[2], L[3], L[4], L[0])
68-
}
69-
7065
fallbackPatterns := [][]*regexp.Regexp{
7166
{regexp.MustCompile(fmt.Sprintf(`%s\\n%s`, L[0], L[1]))},
7267
nil,

internal/stage_q5.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ func testQ5(stageHarness *test_case_harness.TestCaseHarness) error {
6060
fmt.Sprintf(`mixed"quote'%s'\`, L[4]),
6161
fileContents[0] + fileContents[1] + strings.TrimRight(fileContents[2], "\n"),
6262
}
63-
if isTestingTesterUsingDashOnAlpine(stageHarness) {
64-
expectedOutputs[0] = fmt.Sprintf(`%s'%s''%s`, L[0], L[1], L[2])
65-
}
6663
testCaseContents := newTestCaseContents(inputs, expectedOutputs)
6764

6865
for _, testCaseContent := range testCaseContents[:3] {

internal/utils_sys.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,12 @@ import (
1010
const ASH_PATH = "internal/test_helpers/ash/your_shell.sh"
1111
const DASH_PATH = "internal/test_helpers/dash/your_shell.sh"
1212

13-
func isTestingTesterUsingAshOnAlpine(stageHarness *test_case_harness.TestCaseHarness) bool {
13+
func isTestingTesterUsingBusyboxOnAlpine(stageHarness *test_case_harness.TestCaseHarness) bool {
1414
path := stageHarness.Executable.Path
15-
isTestingTesterUsingBusyboxAsh := strings.HasSuffix(path, ASH_PATH)
15+
isTestingTesterUsingBusybox := strings.HasSuffix(path, ASH_PATH) || strings.HasSuffix(path, DASH_PATH)
1616

1717
_, err := os.Stat("/etc/alpine-release")
1818
isOnAlpine := err == nil
1919

20-
return isTestingTesterUsingBusyboxAsh && isOnAlpine
21-
}
22-
23-
func isTestingTesterUsingDashOnAlpine(stageHarness *test_case_harness.TestCaseHarness) bool {
24-
path := stageHarness.Executable.Path
25-
isTestingTesterUsingBusyboxDash := strings.HasSuffix(path, DASH_PATH)
26-
27-
_, err := os.Stat("/etc/alpine-release")
28-
isOnAlpine := err == nil
29-
30-
return isTestingTesterUsingBusyboxDash && isOnAlpine
20+
return isTestingTesterUsingBusybox && isOnAlpine
3121
}

0 commit comments

Comments
 (0)