Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanhammond committed Apr 19, 2023
1 parent d008b30 commit 0b14b5f
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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": {}
}
}
Original file line number Diff line number Diff line change
@@ -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": {}
}
}
Original file line number Diff line number Diff line change
@@ -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": {}
}
}
Original file line number Diff line number Diff line change
@@ -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": {}
}
}
Original file line number Diff line number Diff line change
@@ -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": {}
}
}
Original file line number Diff line number Diff line change
@@ -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": {}
}
}
Original file line number Diff line number Diff line change
@@ -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": {}
}
}
Original file line number Diff line number Diff line change
@@ -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": {}
}
}
32 changes: 32 additions & 0 deletions cli/integration_tests/edit_turbo_json/global.t
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions cli/integration_tests/edit_turbo_json/task.t
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 0b14b5f

Please sign in to comment.