Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasLYang committed Aug 8, 2024
1 parent 1625eb1 commit d7d3fec
Showing 1 changed file with 44 additions and 19 deletions.
63 changes: 44 additions & 19 deletions turborepo-tests/integration/tests/affected.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ Edit a file that affects `my-app`

Validate that we only run `my-app#build` with change not committed
$ ${TURBO} run build --affected --log-order grouped
\xe2\x80\xa2 Packages in scope: my-app (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:build: cache miss, executing 97b34acb6e848096
my-app:build:
my-app:build: > build
Expand All @@ -25,16 +22,19 @@ Validate that we only run `my-app#build` with change not committed
Time:\s*[\.0-9]+m?s (re)


Do the same thing with the `ls` command
$ ${TURBO} ls --affected
WARNING ls command is experimental and may change in the future
1 package

my-app apps/my-app

Commit the change
$ git add .
$ git commit -m "add foo" --quiet

Validate that we only run `my-app#build` with change committed
$ ${TURBO} run build --affected --log-order grouped
\xe2\x80\xa2 Packages in scope: my-app (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:build: cache hit, replaying logs 97b34acb6e848096
my-app:build:
my-app:build: > build
Expand All @@ -47,12 +47,15 @@ Validate that we only run `my-app#build` with change committed
Time:\s*[\.0-9]+m?s >>> FULL TURBO (re)


Do the same thing with the `ls` command
$ ${TURBO} ls --affected
WARNING ls command is experimental and may change in the future
1 package

my-app apps/my-app

Override the SCM base to be HEAD, so nothing runs
$ TURBO_SCM_BASE="HEAD" ${TURBO} run build --affected --log-order grouped
\xe2\x80\xa2 Packages in scope: (esc)
\xe2\x80\xa2 Running build in 0 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

No tasks were executed as part of this run.

Expand All @@ -61,11 +64,15 @@ Override the SCM base to be HEAD, so nothing runs
Time:\s*[\.0-9]+m?s (re)


Do the same thing with the `ls` command
$ TURBO_SCM_BASE="HEAD" ${TURBO} ls --affected
WARNING ls command is experimental and may change in the future
0 packages



Override the SCM head to be main, so nothing runs
$ TURBO_SCM_HEAD="main" ${TURBO} run build --affected --log-order grouped
\xe2\x80\xa2 Packages in scope: (esc)
\xe2\x80\xa2 Running build in 0 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

No tasks were executed as part of this run.

Expand All @@ -74,6 +81,13 @@ Override the SCM head to be main, so nothing runs
Time:\s*[\.0-9]+m?s (re)


Do the same thing with the `ls` command
$ TURBO_SCM_HEAD="main" ${TURBO} ls --affected
WARNING ls command is experimental and may change in the future
0 packages



Now add a commit to `main` so the merge base is different from `main`
$ git checkout main --quiet
$ echo "foo" >> packages/util/index.js
Expand All @@ -84,9 +98,6 @@ Now add a commit to `main` so the merge base is different from `main`
Run the build and expect only `my-app` to be affected, since between
`git merge-base main my-branch` and `my-branch` that is the only changed package.
$ ${TURBO} run build --affected --log-order grouped
\xe2\x80\xa2 Packages in scope: my-app (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:build: cache hit, replaying logs 97b34acb6e848096
my-app:build:
my-app:build: > build
Expand All @@ -98,7 +109,12 @@ Run the build and expect only `my-app` to be affected, since between
Cached: 1 cached, 1 total
Time:\s*[\.0-9]+m?s >>> FULL TURBO (re)


Do the same thing with the `ls` command
$ ${TURBO} ls --affected
WARNING ls command is experimental and may change in the future
1 package

my-app apps/my-app

Now do some magic to change the repo to be shallow
$ SHALLOW=$(git rev-parse --show-toplevel)/.git/shallow
Expand All @@ -111,9 +127,6 @@ Now try running `--affected` again, we should run all tasks
$ ${TURBO} run build --affected --log-order grouped
WARNING unable to detect git range, assuming all files have changed: git error: fatal: main...HEAD: no merge base

\xe2\x80\xa2 Packages in scope: //, another, my-app, util (esc)
\xe2\x80\xa2 Running build in 4 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:build: cache hit, replaying logs 97b34acb6e848096
my-app:build:
my-app:build: > build
Expand All @@ -131,3 +144,15 @@ Now try running `--affected` again, we should run all tasks
Cached: 1 cached, 2 total
Time:\s*[\.0-9]+m?s (re)

Do the same thing with the `ls` command
$ ${TURBO} ls --affected
WARNING ls command is experimental and may change in the future
WARNING unable to detect git range, assuming all files have changed: git error: fatal: main...HEAD: no merge base

4 packages

another packages/another
my-app apps/my-app
util packages/util


0 comments on commit d7d3fec

Please sign in to comment.