aboutsummaryrefslogtreecommitdiff
path: root/src/os/os_windows_test.go
diff options
context:
space:
mode:
authorGeorge Adams <georgeadams1995@gmail.com>2024-11-19 10:05:27 +0000
committerGopher Robot <gobot@golang.org>2024-11-19 17:26:40 +0000
commit5deea4c2425fd8aa6dee642c63a1bc43e090d04b (patch)
tree081b394780d619b01d8b02aeea61833ed84530fc /src/os/os_windows_test.go
parent405a0c4ae86fe2761118ee6d1d59e59daf9b50cd (diff)
downloadgo-5deea4c2425fd8aa6dee642c63a1bc43e090d04b.tar.xz
Revert "os: check for valid Windows path when creating files"
This reverts commit CL 618496. Reason for revert: https://github.com/golang/go/issues/54040#issuecomment-2485151973 Change-Id: I3bf27f7fdd475a005cb6aa190994153504e96fb5 Reviewed-on: https://go-review.googlesource.com/c/go/+/629595 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/os/os_windows_test.go')
-rw-r--r--src/os/os_windows_test.go73
1 files changed, 0 insertions, 73 deletions
diff --git a/src/os/os_windows_test.go b/src/os/os_windows_test.go
index 9208fe3b16..31c379011c 100644
--- a/src/os/os_windows_test.go
+++ b/src/os/os_windows_test.go
@@ -1563,76 +1563,3 @@ func TestReadDirNoFileID(t *testing.T) {
t.Errorf("SameFile(%v, %v) = false; want true", f2, f2s)
}
}
-
-func TestOpen_InvalidPath(t *testing.T) {
- dir := t.TempDir()
-
- file, err := os.Open(dir + ".")
- if err != nil {
- t.Errorf("Open(%q) should have succeeded, got %v", dir+".", err)
- } else {
- file.Close()
- }
-
- file, err = os.Open(dir + " ")
- if err != nil {
- t.Errorf("Open(%q) should have succeeded, got %v", dir+" ", err)
- } else {
- file.Close()
- }
-}
-
-func TestMkdirAll_InvalidPath(t *testing.T) {
- // Parent folder contains traling spaces
- path := `C:\temp\folder \this one fails`
- err := os.MkdirAll(path, 0644)
- if err == nil {
- t.Errorf("MkdirAll(%q) should have failed", path)
- } else if !strings.Contains(err.Error(), "invalid path: cannot end with a space or period") {
- t.Errorf("expected errInvalidPath for path %q, got %v", path, err)
- }
-}
-
-func TestCreate_InvalidPath(t *testing.T) {
- testInvalidPath(t, func(_, path string) error {
- _, err := os.Create(path)
- return err
- })
-}
-
-func TestMkdir_InvalidPath(t *testing.T) {
- testInvalidPath(t, func(_, path string) error {
- return os.Mkdir(path, 0644)
- })
-}
-
-func TestRename_InvalidPath(t *testing.T) {
- testInvalidPath(t, os.Rename)
-}
-
-func TestLink_InvalidPath(t *testing.T) {
- testInvalidPath(t, os.Link)
-}
-
-func TestSymlink_InvalidPath(t *testing.T) {
- testInvalidPath(t, os.Symlink)
-}
-
-func testInvalidPath(t *testing.T, fn func(src, dest string) error) {
- dir := t.TempDir()
-
- // Test invalid paths (with trailing space and period)
- invalidPaths := []string{
- filepath.Join(dir, "invalid_dir "), // path ending in space
- filepath.Join(dir, "invalid_dir."), // path ending in period
- }
-
- for _, path := range invalidPaths {
- err := fn(dir, path)
- if err == nil {
- t.Errorf("(%q, %q) should have failed", dir, path)
- } else if !strings.Contains(err.Error(), "invalid path: cannot end with a space or period") {
- t.Errorf("expected errInvalidPath for path %q, got %v", path, err)
- }
- }
-}