-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
all: Grand test refactor for Go 1.20, other fixes #8889
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
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 <eric@kastelo.net>
As it fails the tests, yeah, but I can remove it. Looks like the |
@calmh Yeah, I only tested on 1.20.3. The |
@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())
}
} |
@rasa thanks I adopted your change into the relevant commit 👍 |
Co-authored-by: Jakob Borg <jakob@kastelo.net>
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.
The non-test changes seem perfectly fine. The important bits of the test-related changes look good to me too.
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