Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasLYang committed Jul 30, 2024
1 parent 159bbff commit df5a542
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
63 changes: 63 additions & 0 deletions turborepo-tests/integration/tests/affected.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Setup
$ . ${TESTDIR}/../../helpers/setup_integration_test.sh

Create a new branch
$ git checkout -b my-branch
Switched to a new branch 'my-branch'

Edit and commit a file that affects `my-app`
$ echo "foo" >> apps/my-app/index.js
$ git add .
$ git commit -m "add foo" --quiet

Validate that we only run `my-app#build`
$ ${TURBO} run build --affected
\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
my-app:build: > echo building
my-app:build:
my-app:build: building

Tasks: 1 successful, 1 total
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)



Now do some magic to change the repo to be shallow
$ SHALLOW=$(git rev-parse --show-toplevel)/.git/shallow
$ git rev-parse HEAD > "$SHALLOW"
$ git reflog expire --expire=0
$ git prune
$ git prune-packed

Now try running `--affected` again, we should run all tasks
$ ${TURBO} run build --affected
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)
util:build: cache miss, executing bf1798d3e46e1b48
my-app:build: cache hit, replaying logs 97b34acb6e848096
my-app:build:
my-app:build: > build
my-app:build: > echo building
my-app:build:
my-app:build: building
util:build:
util:build: > build
util:build: > echo building
util:build:
util:build: building

Tasks: 2 successful, 2 total
Cached: 1 cached, 2 total
Time:\s*[\.0-9]+m?s (re)



2 changes: 2 additions & 0 deletions turborepo-tests/integration/tests/no-args.t
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ Make sure exit code is 2 when no args are passed
Environment variable mode. Use "loose" to pass the entire existing environment. Use "strict" to use an allowlist specified in turbo.json [possible values: loose, strict]
-F, --filter <FILTER>
Use the given selector to specify package(s) to act as entry points. The syntax mirrors pnpm's syntax, and additional documentation and examples can be found in turbo's documentation https://turbo.build/repo/docs/reference/command-line-reference/run#--filter
--affected
Run only tasks that are affected by changes between the current branch and `main`
--output-logs <OUTPUT_LOGS>
Set type of process output logging. Use "full" to show all output. Use "hash-only" to show only turbo-computed task hashes. Use "new-only" to show only new output with only hashes for cached tasks. Use "none" to hide process output. (default full) [possible values: full, none, hash-only, new-only, errors-only]
--log-order <LOG_ORDER>
Expand Down
5 changes: 5 additions & 0 deletions turborepo-tests/integration/tests/turbo-help.t
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ Test help flag
Environment variable mode. Use "loose" to pass the entire existing environment. Use "strict" to use an allowlist specified in turbo.json [possible values: loose, strict]
-F, --filter <FILTER>
Use the given selector to specify package(s) to act as entry points. The syntax mirrors pnpm's syntax, and additional documentation and examples can be found in turbo's documentation https://turbo.build/repo/docs/reference/command-line-reference/run#--filter
--affected
Run only tasks that are affected by changes between the current branch and `main`
--output-logs <OUTPUT_LOGS>
Set type of process output logging. Use "full" to show all output. Use "hash-only" to show only turbo-computed task hashes. Use "new-only" to show only new output with only hashes for cached tasks. Use "none" to hide process output. (default full) [possible values: full, none, hash-only, new-only, errors-only]
--log-order <LOG_ORDER>
Expand Down Expand Up @@ -275,6 +277,9 @@ Test help flag
-F, --filter <FILTER>
Use the given selector to specify package(s) to act as entry points. The syntax mirrors pnpm's syntax, and additional documentation and examples can be found in turbo's documentation https://turbo.build/repo/docs/reference/command-line-reference/run#--filter

--affected
Run only tasks that are affected by changes between the current branch and `main`

--output-logs <OUTPUT_LOGS>
Set type of process output logging. Use "full" to show all output. Use "hash-only" to show only turbo-computed task hashes. Use "new-only" to show only new output with only hashes for cached tasks. Use "none" to hide process output. (default full)

Expand Down

0 comments on commit df5a542

Please sign in to comment.