-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: lake: more robust trace reading (#4518)
The recent change of the trace format exposed some unexpected issues with Lake's tracing handling. This aims to fix that. Lake will now perform a rebuild if the trace file is invalid/unreadable. However, it will still fall back to modification times if the trace file is missing. Also, Lake is now backwards compatible with the previous pure numeric traces (and tolerates the absence of a `log` field in the JSON trace). (cherry picked from commit f32780d)
- Loading branch information
Showing
7 changed files
with
93 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rm -rf .lake lake-manifest.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name = "test" | ||
defaultTargets = ["Foo"] | ||
|
||
[[lean_lib]] | ||
name = "Foo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
|
||
LAKE=${LAKE:-../../.lake/build/bin/lake} | ||
|
||
./clean.sh | ||
|
||
# --- | ||
# Tests aspects of Lake tracing | ||
# --- | ||
|
||
# Tests that a build produces a trace | ||
test ! -f .lake/build/lib/Foo.trace | ||
$LAKE build | grep --color "Built Foo" | ||
test -f .lake/build/lib/Foo.trace | ||
|
||
# Tests that a proper trace prevents a rebuild | ||
$LAKE build --no-build | ||
|
||
# Tests that Lake accepts pure numerical traces | ||
if command -v jq > /dev/null; then # skip if no jq found | ||
jq -r '.depHash' .lake/build/lib/Foo.trace > .lake/build/lib/Foo.trace.hash | ||
mv .lake/build/lib/Foo.trace.hash .lake/build/lib/Foo.trace | ||
$LAKE build --no-build | ||
fi | ||
|
||
# Tests that removal of the trace does not cause a rebuild | ||
# (if the modification time of the artifact is still newer than the inputs) | ||
rm .lake/build/lib/Foo.trace | ||
$LAKE build --no-build | ||
|
||
# Tests that an invalid trace does cause a rebuild | ||
touch .lake/build/lib/Foo.trace | ||
$LAKE build | grep --color "Built Foo" | ||
$LAKE build --no-build |