forked from earthly/earthly
-
Notifications
You must be signed in to change notification settings - Fork 12
feat: push tests down - test more at go level #569
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
Open
gilescope
wants to merge
6
commits into
main
Choose a base branch
from
giles-ast-version-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d919aee
feat: push tests down - test more at go level
gilescope b27afc6
feat: remove the old integration tests
gilescope 1d73b30
Merge branch 'main' into giles-ast-version-tests
gilescope 07570ab
fix: reduce diff - shouldn't have rolled back this version
gilescope c435334
chore: merge main
gilescope 48296d9
Merge branch 'main' into giles-ast-version-tests
gilescope 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
internal/earthfile/testdata/version/invalid-format-version.earth
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 @@ | ||
| VERSION 0.8 --try # we should consider making this format valid, but for now it isn't and we should test it |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,5 @@ | ||
| VERSION 0.8 | ||
|
|
||
| FROM alpine:3.24.0 | ||
| test: | ||
| RUN echo "pass" |
6 changes: 6 additions & 0 deletions
6
internal/earthfile/testdata/version/version-only-import.earth
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,6 @@ | ||
| VERSION 0.8 | ||
| IMPORT ./subdir AS empty-earthfile-only-containing-a-version | ||
|
|
||
| test: | ||
| FROM alpine:3.24.0 | ||
| RUN echo "pass" |
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 @@ | ||
| VERSION 0.8 |
File renamed without changes.
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 was deleted.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests duplicate what the table tests in the TestParse already do.
Extend the table tests for missing scenarios in TestParse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I retained the previous
asttests ininternal/earthfile/testdatato avoid making big changes and keep the change scope as small as possible when implementing parsing.In reality, the tests in this dir have been transferred into table tests in TestParse(). Effectively, these tests are run twice: as unit tests and as higher-level tests +test-ast later.
This requires a better understanding of what
earthly debug astdoes. My current assumption is we can remove "+test-ast" andinternal/earthfile/testdata, and leave only unit tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dug into what
earthly debug astactually does: it's a thin wrapper -earthfile.ParseFile+json.Marshal+ print (cmd/earthly/subcmd/debug_cmds.go). No buildkit involvement beyond the test harness itself.So
+test-astguards two things the unit tests don't:TestParsecompares Go structs, so a struct-tag change would pass unit tests while silently changingdebug astoutput for any external consumer of that JSON. Worth checking whether anything (editor/LSP tooling?) still consumes it before declaring the format free to change.tests/. Downside: brittle goldens - two.ast.jsonfiles changed in this PR just because a dind image bump touched the source.earthfiles.Proposal: replace rather than delete. A plain Go golden test in
internal/earthfilethat walks the existing*.ast.jsonfiles, parses the paired.earth, marshals, and diffs normalised JSON keeps both of the above at unit-test cost. Then+test-ast,tests+ast-test-input, and the binary round-trip can go (perhaps keeping onedebug astCLI smoke, same pattern as the slimmedtests/version).On the duplication in this file: agreed - folded. The invalid VERSION cases now live in
TestParseErrors, the valid spellings in aTestVersionVariantstable with inline inputs assertingVersion.Args, andinternal/earthfile/testdata/is deleted. (invalid-feature-flag-override.earthwas already covered inline infeatures/features_test.go, so that fixture went too.) Will be in the next push.