Skip to content

Commit

Permalink
Reduce boilerplate in run sumamry tests and move to subdir
Browse files Browse the repository at this point in the history
  • Loading branch information
mehulkar committed Mar 27, 2023
1 parent ddda39e commit c1777d2
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 69 deletions.
3 changes: 3 additions & 0 deletions cli/integration_tests/basic_monorepo/get-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

cat "$1" | jq ".tasks | map(select(.taskId == \"$2#build\")) | .[0]"
69 changes: 0 additions & 69 deletions cli/integration_tests/basic_monorepo/run_summary.t

This file was deleted.

84 changes: 84 additions & 0 deletions cli/integration_tests/basic_monorepo/run_summary/run_summary.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
Setup
$ . ${TESTDIR}/../setup.sh
$ . ${TESTDIR}/setup.sh $(pwd)

# Delete all run summaries
$ rm -rf .turbo/runs

$ TURBO_RUN_SUMMARY=true ${TURBO} run build -- someargs > /dev/null # first run (should be cache miss)
$ TURBO_RUN_SUMMARY=true ${TURBO} run build -- someargs > /dev/null # run again (expecting full turbo here)

# no output, just check for 0 status code, which means the directory was created
$ test -d .turbo/runs
# expect 2 run summaries are created
$ ls .turbo/runs/*.json | wc -l
\s*2 (re)

# get jq-parsed output of each run summary
$ FIRST=$(/bin/ls .turbo/runs/*.json | head -n1)
$ SECOND=$(/bin/ls .turbo/runs/*.json | tail -n1)

# some top level run summary validation
$ cat $FIRST | jq '.tasks | length'
2
$ cat $FIRST | jq '.version'
"0"
$ cat $FIRST | jq '.executionSummary.attempted'
2
$ cat $FIRST | jq '.executionSummary.cached'
0
$ cat $FIRST | jq '.executionSummary.failed'
0
$ cat $FIRST | jq '.executionSummary.success'
2
$ cat $FIRST | jq '.executionSummary.startTime'
[0-9]+ (re)
$ cat $FIRST | jq '.executionSummary.endTime'
[0-9]+ (re)

# Extract some task-specific summaries from each
$ FIRST_APP_BUILD=$("$TESTDIR/get-build.sh" "$FIRST" "my-app")
$ FIRST_UTIL_BUILD=$("$TESTDIR/get-build.sh" "$FIRST" "util")
$ SECOND_APP_BUILD=$("$TESTDIR/get-build.sh" "$SECOND" "my-app")
$ SECOND_UTIL_BUILD=$("$TESTDIR/get-build.sh" "$SECOND" "util")

$ echo $FIRST_APP_BUILD | jq '.execution'
{
"startTime": [0-9]+, (re)
"endTime": [0-9]+, (re)
"status": "built",
"error": null,
"exitCode": 0
}
$ echo $FIRST_APP_BUILD | jq '.commandArguments'
[
"someargs"
]

$ echo $FIRST_APP_BUILD | jq '.hashOfExternalDependencies'
"ccab0b28617f1f56"
$ echo $FIRST_APP_BUILD | jq '.expandedOutputs'
[
"apps/my-app/.turbo/turbo-build.log"
]

# Some validation of util#build
$ echo $FIRST_UTIL_BUILD | jq '.execution'
{
"startTime": [0-9]+, (re)
"endTime": [0-9]+, (re)
"status": "built",
"error": null,
"exitCode": 0
}

# another#build is not in tasks, because it didn't execute (script was not implemented)
$ "$TESTDIR/get-build.sh" $FIRST "another"
null

# Without env var, no summary file is generated
$ rm -rf .turbo/runs
$ ${TURBO} run build > /dev/null
# validate with exit code so the test works on macOS and linux
$ test -d .turbo/runs
[1]

0 comments on commit c1777d2

Please sign in to comment.