Repository navigation
all: Grand test refactor for Go 1.20, other fixes - #8889
Merged
Merged
Conversation
This fixes various test issues with Go 1.20. - Most tests rewritten to use fakefs where possible - Some tests that were already skipped, or dubious (invasive, unmaintainable, unclear what they even tested) have been removed - Some actual code rewritten to better support testing in fakefs Co-authored-by: Eric P <[email protected]>
Member
Member
Author
|
As it fails the tests, yeah, but I can remove it. Looks like the |
Member
|
@calmh Yeah, I only tested on 1.20.3. The |
Member
|
@calm Here's the test rewritten to pass on 1.19 and 1.20. Commit to your PR? diff --git a/lib/fs/basicfs.go b/lib/fs/basicfs.go
index 0ec8984ac..51e598ed2 100644
--- a/lib/fs/basicfs.go
+++ b/lib/fs/basicfs.go
@@ -68,11 +68,7 @@ func newBasicFilesystem(root string, opts ...Option) *BasicFilesystem {
// This way in the tests, we get away without OS specific separators
// in the test configs.
sep := string(filepath.Separator)
- if !strings.HasSuffix(root, sep) {
- root = filepath.Dir(root + sep)
- } else {
- root = filepath.Dir(root)
- }
+ root = filepath.Clean(filepath.Dir(root + sep))
// Attempt tilde expansion; leave unchanged in case of error
if path, err := ExpandTilde(root); err == nil {
diff --git a/lib/fs/basicfs_windows_test.go b/lib/fs/basicfs_windows_test.go
index 5526dd220..1cbed7479 100644
--- a/lib/fs/basicfs_windows_test.go
+++ b/lib/fs/basicfs_windows_test.go
@@ -23,18 +23,28 @@ func TestWindowsPaths(t *testing.T) {
expectedRoot string
expectedURI string
}{
+ {`e:`, `\\?\e:\`, `e:\`},
{`e:\`, `\\?\e:\`, `e:\`},
+ {`e:\\`, `\\?\e:\`, `e:\`}, // failed on 1.20
+ {`\\?\e:`, `\\?\e:\`, `e:\`},
{`\\?\e:\`, `\\?\e:\`, `e:\`},
+ {`\\?\e:\\`, `\\?\e:\`, `e:\`}, // failed on 1.20
+ {`e:\x`, `\\?\e:\x`, `e:\x`},
+ {`e:\x\`, `\\?\e:\x`, `e:\x`},
+ {`e:\x\\`, `\\?\e:\x`, `e:\x`},
+ // {`\\.\e:`, `\\.\e:\`, `e:\`}, // fails on 1.19 but not on 1.20
+ // {`\\.\e:\`, `\\.\e:\`, `e:\`}, // fails on 1.19 but not on 1.20
+ // {`\\.\e:\\`, `\\.\e:\`, `e:\`}, // fails on 1.19 but not on 1.20
{`\\192.0.2.22\network\share`, `\\192.0.2.22\network\share`, `\\192.0.2.22\network\share`},
}
- for _, testCase := range testCases {
+ for i, testCase := range testCases {
fs := newBasicFilesystem(testCase.input)
if fs.root != testCase.expectedRoot {
- t.Errorf("root %q != %q", fs.root, testCase.expectedRoot)
+ t.Errorf("test %d: root: expected `%s`, got `%s`", i, testCase.expectedRoot, fs.root)
}
if fs.URI() != testCase.expectedURI {
- t.Errorf("uri %q != %q", fs.URI(), testCase.expectedURI)
+ t.Errorf("test %d: uri: expected `%s`, got `%s`", i, testCase.expectedURI, fs.URI())
}
} |
calmh
marked this pull request as ready for review
May 9, 2023 04:59
Member
Author
|
@rasa thanks I adopted your change into the relevant commit 👍 |
er-pa
approved these changes
May 9, 2023
er-pa
left a comment
Member
There was a problem hiding this comment.
The non-test changes seem perfectly fine. The important bits of the test-related changes look good to me too.
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This fixes various test issues with Go 1.20, and adds builds and tests on Go 1.20.
unmaintainable, unclear what they even tested) have been removed
Also fix for new Windows path handling, in separate commit, and some build changes.
n.b. no squashy-squishy on this one