From 0b14b5f44229ca3d510c0ff5397ce886365e285a Mon Sep 17 00:00:00 2001 From: Nathan Hammond Date: Wed, 12 Apr 2023 18:28:37 +0800 Subject: [PATCH] add tests --- .../fixture-configs/1-baseline.json | 19 ++++++++++ .../fixture-configs/2-update-pipeline.json | 19 ++++++++++ .../fixture-configs/3-update-global-env.json | 19 ++++++++++ .../fixture-configs/4-update-global-deps.json | 19 ++++++++++ .../5-update-global-deps-materially.json | 19 ++++++++++ .../6-update-passthrough-env.json | 20 +++++++++++ .../fixture-configs/a-baseline.json | 19 ++++++++++ .../fixture-configs/b-change-only-my-app.json | 19 ++++++++++ .../edit_turbo_json/global.t | 32 +++++++++++++++++ cli/integration_tests/edit_turbo_json/task.t | 35 +++++++++++++++++++ 10 files changed, 220 insertions(+) create mode 100644 cli/integration_tests/edit_turbo_json/fixture-configs/1-baseline.json create mode 100644 cli/integration_tests/edit_turbo_json/fixture-configs/2-update-pipeline.json create mode 100644 cli/integration_tests/edit_turbo_json/fixture-configs/3-update-global-env.json create mode 100644 cli/integration_tests/edit_turbo_json/fixture-configs/4-update-global-deps.json create mode 100644 cli/integration_tests/edit_turbo_json/fixture-configs/5-update-global-deps-materially.json create mode 100644 cli/integration_tests/edit_turbo_json/fixture-configs/6-update-passthrough-env.json create mode 100644 cli/integration_tests/edit_turbo_json/fixture-configs/a-baseline.json create mode 100644 cli/integration_tests/edit_turbo_json/fixture-configs/b-change-only-my-app.json create mode 100644 cli/integration_tests/edit_turbo_json/global.t create mode 100644 cli/integration_tests/edit_turbo_json/task.t diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/1-baseline.json b/cli/integration_tests/edit_turbo_json/fixture-configs/1-baseline.json new file mode 100644 index 0000000000000..bd301c8c5ae15 --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/1-baseline.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo.txt"], + "globalEnv": ["SOME_ENV_VAR"], + "pipeline": { + "build": { + "env": ["NODE_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["banana.txt", "apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/2-update-pipeline.json b/cli/integration_tests/edit_turbo_json/fixture-configs/2-update-pipeline.json new file mode 100644 index 0000000000000..64ea6bc8443c0 --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/2-update-pipeline.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo.txt"], + "globalEnv": ["SOME_ENV_VAR"], + "pipeline": { + "build": { + "env": ["NODE_ENV", "NEW_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["banana.txt", "apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/3-update-global-env.json b/cli/integration_tests/edit_turbo_json/fixture-configs/3-update-global-env.json new file mode 100644 index 0000000000000..25b22ced860fb --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/3-update-global-env.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo.txt"], + "globalEnv": ["SOME_ENV_VAR", "NEW_ENV"], + "pipeline": { + "build": { + "env": ["NODE_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["banana.txt", "apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/4-update-global-deps.json b/cli/integration_tests/edit_turbo_json/fixture-configs/4-update-global-deps.json new file mode 100644 index 0000000000000..7d3890d08051b --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/4-update-global-deps.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo*.txt"], + "globalEnv": ["SOME_ENV_VAR"], + "pipeline": { + "build": { + "env": ["NODE_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["banana.txt", "apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/5-update-global-deps-materially.json b/cli/integration_tests/edit_turbo_json/fixture-configs/5-update-global-deps-materially.json new file mode 100644 index 0000000000000..228e5cdb61fe8 --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/5-update-global-deps-materially.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo.txt", "bar.txt"], + "globalEnv": ["SOME_ENV_VAR"], + "pipeline": { + "build": { + "env": ["NODE_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["banana.txt", "apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/6-update-passthrough-env.json b/cli/integration_tests/edit_turbo_json/fixture-configs/6-update-passthrough-env.json new file mode 100644 index 0000000000000..b2f7149a254aa --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/6-update-passthrough-env.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo.txt"], + "globalEnv": ["SOME_ENV_VAR"], + "experimentalGlobalPassThroughEnv": ["PASSTHROUGH"], + "pipeline": { + "build": { + "env": ["NODE_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["banana.txt", "apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/a-baseline.json b/cli/integration_tests/edit_turbo_json/fixture-configs/a-baseline.json new file mode 100644 index 0000000000000..bd301c8c5ae15 --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/a-baseline.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo.txt"], + "globalEnv": ["SOME_ENV_VAR"], + "pipeline": { + "build": { + "env": ["NODE_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["banana.txt", "apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/b-change-only-my-app.json b/cli/integration_tests/edit_turbo_json/fixture-configs/b-change-only-my-app.json new file mode 100644 index 0000000000000..ec4a69bbffcff --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/b-change-only-my-app.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo.txt"], + "globalEnv": ["SOME_ENV_VAR"], + "pipeline": { + "build": { + "env": ["NODE_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/global.t b/cli/integration_tests/edit_turbo_json/global.t new file mode 100644 index 0000000000000..39fc736401eb9 --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/global.t @@ -0,0 +1,32 @@ +Setup + $ . ${TESTDIR}/../_helpers/setup.sh + $ . ${TESTDIR}/../_helpers/setup_monorepo.sh $(pwd) + +Baseline global hash + $ cp "$TESTDIR/fixture-configs/1-baseline.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ BASELINE=$(${TURBO} build -vv 2>&1 | "$TESTDIR/../_helpers/get-global-hash.sh") + +Update pipeline: global hash remains stable. + $ cp "$TESTDIR/fixture-configs/2-update-pipeline.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ UPDATE_PIPELINE=$(${TURBO} build -vv --experimental-env-mode=infer 2>&1 | "$TESTDIR/../_helpers/get-global-hash.sh") + $ test $BASELINE = $UPDATE_PIPELINE + +Update globalEnv: global hash changes. + $ cp "$TESTDIR/fixture-configs/3-update-global-env.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ NEW_GLOBAL_ENV=$(${TURBO} build -vv --experimental-env-mode=infer 2>&1 | "$TESTDIR/../_helpers/get-global-hash.sh") + $ test $BASELINE != $NEW_GLOBAL_ENV + +Update globalDeps in a non-material way: global hash remains stable. + $ cp "$TESTDIR/fixture-configs/4-update-global-deps.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ NEW_GLOBAL_DEPS=$(${TURBO} build -vv --experimental-env-mode=infer 2>&1 | "$TESTDIR/../_helpers/get-global-hash.sh") + $ test $BASELINE = $NEW_GLOBAL_DEPS + +Update globalDeps in a material way: global hash changes. + $ cp "$TESTDIR/fixture-configs/5-update-global-deps-materially.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ NEW_GLOBAL_DEPS=$(${TURBO} build -vv --experimental-env-mode=infer 2>&1 | "$TESTDIR/../_helpers/get-global-hash.sh") + $ test $BASELINE != $NEW_GLOBAL_DEPS + +Update passthroughEnv: global hash changes. + $ cp "$TESTDIR/fixture-configs/6-update-passthrough-env.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ NEW_GLOBAL_PASSTHROUGH=$(${TURBO} build -vv --experimental-env-mode=infer 2>&1 | "$TESTDIR/../_helpers/get-global-hash.sh") + $ test $BASELINE != $NEW_GLOBAL_PASSTHROUGH diff --git a/cli/integration_tests/edit_turbo_json/task.t b/cli/integration_tests/edit_turbo_json/task.t new file mode 100644 index 0000000000000..0a09c8b1ba06d --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/task.t @@ -0,0 +1,35 @@ +Setup + $ . ${TESTDIR}/../_helpers/setup.sh + $ . ${TESTDIR}/../_helpers/setup_monorepo.sh $(pwd) + +Baseline task hashes + $ cp "$TESTDIR/fixture-configs/a-baseline.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ ${TURBO} build --dry=json | jq -r '.tasks | sort_by(.taskId)[] | {taskId, hash}' + { + "taskId": "another#build", + "hash": "4c4f0e076ebc3a2a" + } + { + "taskId": "my-app#build", + "hash": "9431e2a02286769a" + } + { + "taskId": "util#build", + "hash": "e6ceb7aa9a6948f8" + } + +Change only my-app#build + $ cp "$TESTDIR/fixture-configs/b-change-only-my-app.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ ${TURBO} build --dry=json | jq -r '.tasks | sort_by(.taskId)[] | {taskId, hash}' + { + "taskId": "another#build", + "hash": "4c4f0e076ebc3a2a" + } + { + "taskId": "my-app#build", + "hash": "WAT" + } + { + "taskId": "util#build", + "hash": "e6ceb7aa9a6948f8" + }