-
Notifications
You must be signed in to change notification settings - Fork 2
Generalizes golden script tests #469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Generalizes golden script tests #469
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Generalizes golden bash tests to support arbitrary scripting environments by introducing a generic ScriptTest
framework. Key changes:
- Renames
BashTest
/BashConfig
toScriptTest
/ScriptConfig
and updates the consuming code. - Adds a
ScriptExtensions
map to configure commands for different file extensions. - Updates existing tests to pass
ScriptConfig
while keeping aBashTest
wrapper for backward compatibility.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
run/tests/simple/main_test.go | Switched from BashConfig to ScriptConfig in simple test. |
run/tests/http/too_many_requests/main_test.go | Same switch in HTTP too-many-requests test. |
run/tests/http/sync/main_test.go | Same switch in HTTP sync test. |
run/tests/http/error_log/main_test.go | Same switch in HTTP error-log test. |
run/tests/http/async/main_test.go | Same switch in HTTP async test. |
golden/script.go | Introduced generic ScriptTest logic; removed hardcoded .sh paths. |
golden/dag.go | Updated DagTest to use ScriptConfig instead of BashConfig . |
golden/config.go | Renamed BashConfig to ScriptConfig and added ScriptExtensions . |
Comments suppressed due to low confidence (5)
golden/script.go:38
- [nitpick] Update the doc comment to clarify that
ScriptTest
considers all extensions provided inScriptExtensions
, not just.sh
files.
// ScriptTest executes a golden file test for scripts. It walks over the
run/tests/simple/main_test.go:41
- [nitpick] The test function is still named
TestGoldenBash
but now runs generic scripts; consider renaming it toTestGoldenScript
to reflect the new behavior.
func TestGoldenBash(t *testing.T) {
golden/script.go:10
- Add missing imports for packages used in this file: fmt (for fmt.Sprintf and fmt.Errorf), bytes (for bytes.Buffer), and encoding/json (for JSON marshal/unmarshal in processOutput).
"slices"
golden/dag.go:74
- Initializing
ScriptConfig
without defaultingScriptExtensions
meansScriptTest
will fail; consider settingScriptExtensions = map[string]string{".sh":"bash"}
whenConfig
is nil or require it in the test cases.
config := ScriptConfig{}
golden/script.go:198
- [nitpick] Using the full script path as the subtest name may be too verbose; consider using
filepath.Base(script)
for a concise test name.
t.Run(script, f)
…script-tests' into merschformann/generalize-golden-script-tests
…ralize-golden-script-tests
Description
Generalizes former golden bash tests to golden script tests, i.e., allows use of the tooling for other scripting environments like PowerShell, etc..
Changes
You can now specify how your scripts need to be run:
This allows you to run PowerShell, other scripts or even totally different tools with the same functionality. Just define a specific extension for them and a command to run them.
BashTest
was renamed toScriptTest
to better reflect the new functionality.BashTestFile
was renamed toScriptTestFile
and now accepts a command for running the script (instead of fixing it tobash
).BashTestFile
andBashTest
are still available for backwards compatibility reasons though.Resolves ENG-6270