Skip to content

Commit

Permalink
feat: add ash shell error patterns to FallbackPatterns
Browse files Browse the repository at this point in the history
Added ash shell error patterns to handle:
- Command not found messages (stages 2-4)
- Type builtin messages (stage 6)
- Type not found messages (stage 7)
- CD error messages (stage 10)

All patterns follow the ash format: 'ash: \d+: command: not found'

Co-Authored-By: Paul Kuruvilla <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and rohitpaulk committed Dec 27, 2024
1 parent 2231fbf commit d4cca7b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions internal/stage10.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func testCd1(stageHarness *test_case_harness.TestCaseHarness) error {
ExpectedOutput: fmt.Sprintf(`cd: %s: No such file or directory`, directory),
FallbackPatterns: []*regexp.Regexp{
regexp.MustCompile(fmt.Sprintf(`^(can't cd to %s|((bash: )?cd: )?%s: No such file or directory)$`, directory, directory)),
regexp.MustCompile(fmt.Sprintf(`^ash: \d+: cd: can't cd to %s$`, directory)),
},
SuccessMessage: "✓ Received error message",
}
Expand Down
1 change: 1 addition & 0 deletions internal/stage2.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func testInvalidCommand(stageHarness *test_case_harness.TestCaseHarness) error {
FallbackPatterns: []*regexp.Regexp{
regexp.MustCompile(fmt.Sprintf(`^bash: %s: command not found$`, invalidCommand)),
regexp.MustCompile(fmt.Sprintf(`^%s: command not found$`, invalidCommand)),
regexp.MustCompile(fmt.Sprintf(`^ash: \d+: %s: not found$`, invalidCommand)),
},
})

Expand Down
1 change: 1 addition & 0 deletions internal/stage3.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func testREPL(stageHarness *test_case_harness.TestCaseHarness) error {
FallbackPatterns: []*regexp.Regexp{
regexp.MustCompile(fmt.Sprintf(`^bash: %s: command not found$`, command)),
regexp.MustCompile(fmt.Sprintf(`^%s: command not found$`, command)),
regexp.MustCompile(fmt.Sprintf(`^ash: \d+: %s: not found$`, command)),
},
SuccessMessage: "✓ Received command not found message",
}
Expand Down
5 changes: 4 additions & 1 deletion internal/stage4.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ func testExit(stageHarness *test_case_harness.TestCaseHarness) error {
testCase := test_cases.CommandResponseTestCase{
Command: invalidCommand,
ExpectedOutput: invalidCommand + ": command not found",
FallbackPatterns: []*regexp.Regexp{regexp.MustCompile(`^(bash: )?` + invalidCommand + `: (command )?not found$`)},
FallbackPatterns: []*regexp.Regexp{
regexp.MustCompile(`^(bash: )?` + invalidCommand + `: (command )?not found$`),
regexp.MustCompile(fmt.Sprintf(`^ash: \d+: %s: not found$`, invalidCommand)),
},
SuccessMessage: "✓ Received command not found message",
}

Expand Down
10 changes: 8 additions & 2 deletions internal/stage6.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ func testType1(stageHarness *test_case_harness.TestCaseHarness) error {
testCase := test_cases.CommandResponseTestCase{
Command: command,
ExpectedOutput: fmt.Sprintf(`%s is a shell builtin`, builtIn),
FallbackPatterns: []*regexp.Regexp{regexp.MustCompile(fmt.Sprintf(`^%s is a( special)? shell builtin$`, builtIn))},
FallbackPatterns: []*regexp.Regexp{
regexp.MustCompile(fmt.Sprintf(`^%s is a( special)? shell builtin$`, builtIn)),
regexp.MustCompile(fmt.Sprintf(`^%s is a shell builtin$`, builtIn)),
},
SuccessMessage: "✓ Received expected response",
}
if err := testCase.Run(asserter, shell, logger); err != nil {
Expand All @@ -43,7 +46,10 @@ func testType1(stageHarness *test_case_harness.TestCaseHarness) error {
testCase := test_cases.CommandResponseTestCase{
Command: command,
ExpectedOutput: fmt.Sprintf("%s: not found", invalidCommand),
FallbackPatterns: []*regexp.Regexp{regexp.MustCompile(fmt.Sprintf(`^(bash: type: )?%s[:]? not found$`, invalidCommand))},
FallbackPatterns: []*regexp.Regexp{
regexp.MustCompile(fmt.Sprintf(`^(bash: type: )?%s[:]? not found$`, invalidCommand)),
regexp.MustCompile(fmt.Sprintf(`^ash: \d+: type: %s: not found$`, invalidCommand)),
},
SuccessMessage: "✓ Received expected response",
}
if err := testCase.Run(asserter, shell, logger); err != nil {
Expand Down
5 changes: 4 additions & 1 deletion internal/stage7.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ func testType2(stageHarness *test_case_harness.TestCaseHarness) error {
testCase := test_cases.CommandResponseTestCase{
Command: command,
ExpectedOutput: fmt.Sprintf(`%s: not found`, executable),
FallbackPatterns: []*regexp.Regexp{regexp.MustCompile(fmt.Sprintf(`^(bash: type: )?%s: not found$`, executable))},
FallbackPatterns: []*regexp.Regexp{
regexp.MustCompile(fmt.Sprintf(`^(bash: type: )?%s: not found$`, executable)),
regexp.MustCompile(fmt.Sprintf(`^ash: \d+: type: %s: not found$`, executable)),
},
SuccessMessage: "✓ Received expected response",
}
if err := testCase.Run(asserter, shell, logger); err != nil {
Expand Down

0 comments on commit d4cca7b

Please sign in to comment.