-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(task): improve source freshness checking with edge case handling #7932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3204679
feat(task): improve source freshness checking with edge case handling
jdx 30a7229
[autofix.ci] apply automated fixes
autofix-ci[bot] dc57b2f
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] 4fb13ed
fix: use portable mtime approach in source freshness tests
jdx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,107 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Test warning for missing outputs after task execution | ||
| cat <<EOF >mise.toml | ||
| [tasks.nooutput] | ||
| run = 'echo ran but no output created' | ||
| sources = ['input.txt'] | ||
| outputs = ['missing_output.txt'] | ||
| EOF | ||
|
|
||
| echo "source" >input.txt | ||
| # Should warn about missing output | ||
| assert_contains "mise run nooutput 2>&1" "did not generate expected output" | ||
|
|
||
| # Test size-based detection (file size changes should trigger rebuild) | ||
| cat <<EOF >mise.toml | ||
| [tasks.sizetest] | ||
| run = 'echo rebuilt' | ||
| sources = ['sized.txt'] | ||
| outputs = ['sizeout.txt'] | ||
| EOF | ||
|
|
||
| echo "small" >sized.txt | ||
| echo "out" >sizeout.txt | ||
| sleep 0.1 | ||
| touch sizeout.txt | ||
|
|
||
| # First run should skip (output is newer) | ||
| assert_empty "mise run -q sizetest" | ||
|
|
||
| # Change file content/size - this changes the metadata hash | ||
| echo "much larger content now" >sized.txt | ||
| # Make output NEWER than source (so mtime comparison alone would say fresh) | ||
| sleep 0.1 | ||
| touch sizeout.txt | ||
| # Should rebuild because size changed in the metadata hash | ||
| assert "mise run -q sizetest" "rebuilt" | ||
|
|
||
| # Test that normal source/output freshness still works | ||
| cat <<EOF >mise.toml | ||
| [tasks.fresh] | ||
| run = 'echo built' | ||
| sources = ['src.txt'] | ||
| outputs = ['out.txt'] | ||
| EOF | ||
|
|
||
| echo "source" >src.txt | ||
| sleep 0.1 | ||
| echo "output" >out.txt | ||
|
|
||
| # Output is newer, should skip | ||
| assert_empty "mise run -q fresh" | ||
|
|
||
| # Touch source to make it newer | ||
| sleep 0.1 | ||
| touch src.txt | ||
|
|
||
| # Source is newer, should rebuild | ||
| assert "mise run -q fresh" "built" | ||
|
|
||
| # Test rename detection (path is part of the hash) | ||
| cat <<EOF >mise.toml | ||
| [tasks.rename] | ||
| run = 'echo rebuilt' | ||
| sources = ['*.src'] | ||
| outputs = ['rename.out'] | ||
| EOF | ||
|
|
||
| echo "content" >original.src | ||
| echo "out" >rename.out | ||
| sleep 0.1 | ||
| touch rename.out | ||
|
|
||
| # First run should skip (output is newer) | ||
| assert_empty "mise run -q rename" | ||
|
|
||
| # Rename the source file (same content, same size, but different path) | ||
| mv original.src renamed.src | ||
| # Make output NEWER than source so only the path change triggers rebuild | ||
| sleep 0.1 | ||
| touch rename.out | ||
| # Should rebuild because path changed in the metadata hash | ||
| assert "mise run -q rename" "rebuilt" | ||
|
|
||
| # Test glob output patterns - should not warn when glob matches files | ||
| cat <<EOF >mise.toml | ||
| [tasks.globout] | ||
| run = 'touch output1.gen output2.gen' | ||
| sources = ['input.txt'] | ||
| outputs = ['*.gen'] | ||
| EOF | ||
|
|
||
| echo "source" >input.txt | ||
| # Should run and NOT warn (glob matches created files) | ||
| assert_not_contains "mise run globout 2>&1" "did not generate expected output" | ||
|
|
||
| # Test glob output patterns - should warn when glob matches no files | ||
| cat <<EOF >mise.toml | ||
| [tasks.noglobout] | ||
| run = 'echo no files created' | ||
| sources = ['input.txt'] | ||
| outputs = ['*.nomatch'] | ||
| EOF | ||
|
|
||
| echo "source" >input.txt | ||
| # Should warn about missing glob output | ||
| assert_contains "mise run noglobout 2>&1" "did not generate expected output" |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -265,7 +265,7 @@ impl TaskExecutor { | |
| ); | ||
| } | ||
|
|
||
| save_checksum(task)?; | ||
| save_checksum(task, config).await?; | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.