Skip to content

Conversation

merschformann
Copy link
Member

@merschformann merschformann commented Jul 14, 2025

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

  • Generalizes golden bash testing to golden script testing.
    • You can now specify how your scripts need to be run:

      ScriptExtensions: map[string]string{
        ".sh": "bash",
      }
    • 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 to ScriptTest to better reflect the new functionality.
  • BashTestFile was renamed to ScriptTestFile and now accepts a command for running the script (instead of fixing it to bash).
  • BashTestFile and BashTest are still available for backwards compatibility reasons though.

Resolves ENG-6270

@merschformann merschformann requested a review from Copilot July 14, 2025 10:08
Copy link
Contributor

@Copilot Copilot AI left a 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 to ScriptTest/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 a BashTest 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 in ScriptExtensions, 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 to TestGoldenScript 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 defaulting ScriptExtensions means ScriptTest will fail; consider setting ScriptExtensions = map[string]string{".sh":"bash"} when Config 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant