aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cli/internal/run/run_spec_test.go
diff options
context:
space:
mode:
author简律纯 <hsiangnianian@outlook.com>2023-04-28 01:36:44 +0800
committer简律纯 <hsiangnianian@outlook.com>2023-04-28 01:36:44 +0800
commitdd84b9d64fb98746a230cd24233ff50a562c39c9 (patch)
treeb583261ef00b3afe72ec4d6dacb31e57779a6faf /cli/internal/run/run_spec_test.go
parent0b46fcd72ac34382387b2bcf9095233efbcc52f4 (diff)
downloadHydroRoll-dd84b9d64fb98746a230cd24233ff50a562c39c9.tar.gz
HydroRoll-dd84b9d64fb98746a230cd24233ff50a562c39c9.zip
Diffstat (limited to 'cli/internal/run/run_spec_test.go')
-rw-r--r--cli/internal/run/run_spec_test.go107
1 files changed, 107 insertions, 0 deletions
diff --git a/cli/internal/run/run_spec_test.go b/cli/internal/run/run_spec_test.go
new file mode 100644
index 0000000..2bcfe2b
--- /dev/null
+++ b/cli/internal/run/run_spec_test.go
@@ -0,0 +1,107 @@
+package run
+
+import (
+ "testing"
+
+ "github.com/vercel/turbo/cli/internal/scope"
+ "github.com/vercel/turbo/cli/internal/util"
+)
+
+func TestSynthesizeCommand(t *testing.T) {
+ testCases := []struct {
+ filterPatterns []string
+ legacyFilter scope.LegacyFilter
+ passThroughArgs []string
+ parallel bool
+ continueOnError bool
+ dryRun bool
+ dryRunJSON bool
+ tasks []string
+ expected string
+ }{
+ {
+ filterPatterns: []string{"my-app"},
+ tasks: []string{"build"},
+ expected: "turbo run build --filter=my-app",
+ },
+ {
+ filterPatterns: []string{"my-app"},
+ tasks: []string{"build"},
+ passThroughArgs: []string{"-v", "--foo=bar"},
+ expected: "turbo run build --filter=my-app -- -v --foo=bar",
+ },
+ {
+ legacyFilter: scope.LegacyFilter{
+ Entrypoints: []string{"my-app"},
+ SkipDependents: true,
+ },
+ tasks: []string{"build"},
+ passThroughArgs: []string{"-v", "--foo=bar"},
+ expected: "turbo run build --filter=my-app -- -v --foo=bar",
+ },
+ {
+ legacyFilter: scope.LegacyFilter{
+ Entrypoints: []string{"my-app"},
+ SkipDependents: true,
+ },
+ filterPatterns: []string{"other-app"},
+ tasks: []string{"build"},
+ passThroughArgs: []string{"-v", "--foo=bar"},
+ expected: "turbo run build --filter=other-app --filter=my-app -- -v --foo=bar",
+ },
+ {
+ legacyFilter: scope.LegacyFilter{
+ Entrypoints: []string{"my-app"},
+ IncludeDependencies: true,
+ Since: "some-ref",
+ },
+ filterPatterns: []string{"other-app"},
+ tasks: []string{"build"},
+ expected: "turbo run build --filter=other-app --filter=...my-app...[some-ref]...",
+ },
+ {
+ filterPatterns: []string{"my-app"},
+ tasks: []string{"build"},
+ parallel: true,
+ continueOnError: true,
+ expected: "turbo run build --filter=my-app --parallel --continue",
+ },
+ {
+ filterPatterns: []string{"my-app"},
+ tasks: []string{"build"},
+ dryRun: true,
+ expected: "turbo run build --filter=my-app --dry",
+ },
+ {
+ filterPatterns: []string{"my-app"},
+ tasks: []string{"build"},
+ dryRun: true,
+ dryRunJSON: true,
+ expected: "turbo run build --filter=my-app --dry=json",
+ },
+ }
+
+ for _, testCase := range testCases {
+ testCase := testCase
+ t.Run(testCase.expected, func(t *testing.T) {
+ o := Opts{
+ scopeOpts: scope.Opts{
+ FilterPatterns: testCase.filterPatterns,
+ LegacyFilter: testCase.legacyFilter,
+ },
+ runOpts: util.RunOpts{
+ PassThroughArgs: testCase.passThroughArgs,
+ Parallel: testCase.parallel,
+ ContinueOnError: testCase.continueOnError,
+ DryRun: testCase.dryRun,
+ DryRunJSON: testCase.dryRunJSON,
+ },
+ }
+ cmd := o.SynthesizeCommand(testCase.tasks)
+ if cmd != testCase.expected {
+ t.Errorf("SynthesizeCommand() got %v, want %v", cmd, testCase.expected)
+ }
+ })
+ }
+
+}