summaryrefslogtreecommitdiffstats
path: root/src/cmd/go/go_windows_test.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:23:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:23:18 +0000
commit43a123c1ae6613b3efeed291fa552ecd909d3acf (patch)
treefd92518b7024bc74031f78a1cf9e454b65e73665 /src/cmd/go/go_windows_test.go
parentInitial commit. (diff)
downloadgolang-1.20-43a123c1ae6613b3efeed291fa552ecd909d3acf.tar.xz
golang-1.20-43a123c1ae6613b3efeed291fa552ecd909d3acf.zip
Adding upstream version 1.20.14.upstream/1.20.14upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/cmd/go/go_windows_test.go')
-rw-r--r--src/cmd/go/go_windows_test.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/cmd/go/go_windows_test.go b/src/cmd/go/go_windows_test.go
new file mode 100644
index 0000000..0c443eb
--- /dev/null
+++ b/src/cmd/go/go_windows_test.go
@@ -0,0 +1,50 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main_test
+
+import (
+ "internal/testenv"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+
+ "cmd/go/internal/robustio"
+)
+
+func TestAbsolutePath(t *testing.T) {
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.parallel()
+
+ tmp, err := os.MkdirTemp("", "TestAbsolutePath")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer robustio.RemoveAll(tmp)
+
+ file := filepath.Join(tmp, "a.go")
+ err = os.WriteFile(file, []byte{}, 0644)
+ if err != nil {
+ t.Fatal(err)
+ }
+ dir := filepath.Join(tmp, "dir")
+ err = os.Mkdir(dir, 0777)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ noVolume := file[len(filepath.VolumeName(file)):]
+ wrongPath := filepath.Join(dir, noVolume)
+ cmd := testenv.Command(t, tg.goTool(), "build", noVolume)
+ cmd.Dir = dir
+ output, err := cmd.CombinedOutput()
+ if err == nil {
+ t.Fatal("build should fail")
+ }
+ if strings.Contains(string(output), wrongPath) {
+ t.Fatalf("wrong output found: %v %v", err, string(output))
+ }
+}