Skip to content

Commit f4e7dfe

Browse files
committed
fix snapshots to handle new assumption (files should be committed)
1 parent aca5c5d commit f4e7dfe

11 files changed

Lines changed: 23 additions & 2 deletions

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ To use it, first build using another system, and the run `taskrunner` with `TASK
130130
- Previous impl no-op tests/scripts/UPDATE: ~1.6s
131131
- Current impl no-op tests/scripts/UPDATE: ~2.3s
132132

133-
## Snapshot Command Flags
133+
## Snapshot Command Flags
134134

135135
The `snapshot` command supports the following flags:
136136

@@ -142,3 +142,15 @@ The `snapshot` command supports the following flags:
142142
- `--cache-version`: Specifies a version string for the cache. `--fuzzy-cache` will not download cache from another version, allowing clean breaks when making big changes, e.g. upgrading a compiler.
143143
- `--commit-status`: Enables reporting of the task's status to a commit status system, such as GitHub checks.
144144
- `--long-running`: Indicates that the task is expected to run for a long time (e.g. a server). Currently doens't have any effect though, TODO: can we remove it?
145+
146+
147+
## Tests: Update Golden Files
148+
149+
This project uses [tasty-golden](https://github.com/UnkindPartition/tasty-golden) for snapshot-based testing.
150+
151+
To update the golden files, run the test suite with the `--accept` flag passed to the test executable.
152+
If you're using stack, the full command is:
153+
154+
```sh
155+
stack test --test-arguments --accept
156+
```

src/App.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ snapshot appState args = do
457457

458458
logInfo appState "Inputs changed, running task"
459459

460-
when (not force && hasRemoteCache args && args.fuzzyCache && mainBranchCommitChanged savedHashInfo hashInfo && inputsAreClean) do
460+
when (not force && hasRemoteCache args && args.fuzzyCache && mainBranchCommitChanged savedHashInfo hashInfo) do
461461
success <- tryRestoreFuzzyCache appState args
462462
when success do
463463
-- Save change in mainBranchCommit, even if the task didn't succeed yet.

src/Utils.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ bytesfmt formatter bs = printf (formatter <> " %s")
8181
bytesSuffix = bytesSuffixes !! i
8282

8383
isDirtyAtPaths :: AppState -> [FilePath] -> IO Bool
84+
isDirtyAtPaths _ [] = pure False
8485
isDirtyAtPaths appState paths =
8586
bracket (hDuplicate appState.subprocessStderr) hClose \stderr_ -> do
8687
output <-

test/t/cache-success-unchanged.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mkdir a
1010
echo foo > input.txt
1111
git init -q
1212
git add input.txt
13+
git commit -qm "Add input.txt"
1314
)
1415

1516
cp -r a b

test/t/prime-cache-mode.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mkdir a
1010
echo foo > input.txt
1111
git init -q
1212
git add input.txt
13+
git commit -qm "Add input.txt"
1314
)
1415

1516
cp -r a b

test/t/remote-cache-changed.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mkdir a
1010
echo foo > input.txt
1111
git init -q
1212
git add input.txt
13+
git commit -qm "Add input.txt"
1314
)
1415

1516
cp -r a b

test/t/remote-cache-post-unpack.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mkdir a
1010
echo foo > input.txt
1111
git init -q
1212
git add input.txt
13+
git commit -qm "Add input.txt"
1314
)
1415

1516
cp -r a b

test/t/remote-cache-unchanged-force.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mkdir a
1010
echo foo > input.txt
1111
git init -q
1212
git add input.txt
13+
git commit -qm "Add input.txt"
1314
)
1415

1516
cp -r a b

test/t/remote-cache-unchanged-nested-dir.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ mkdir -p a
1515
cd nested
1616
echo foo > input.txt
1717
git add input.txt
18+
git commit -qm "Add input.txt"
1819
)
1920

2021
cp -r a b

test/t/remote-cache-unchanged-out-of-repo.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mkdir a
1010
echo foo > input.txt
1111
git init -q
1212
git add input.txt
13+
git commit -qm "Add input.txt"
1314
)
1415

1516
cp -r a b

0 commit comments

Comments
 (0)