File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -1835,3 +1835,32 @@ func TestPathRace(t *testing.T) {
1835
1835
t .Logf ("running in background: %v" , cmd )
1836
1836
<- done
1837
1837
}
1838
+
1839
+ func TestAbsPathExec (t * testing.T ) {
1840
+ testenv .MustHaveExec (t )
1841
+ testenv .MustHaveGoBuild (t ) // must have GOROOT/bin/gofmt, but close enough
1842
+
1843
+ // A simple exec of a full path should work.
1844
+ // Go 1.22 broke this on Windows, requiring ".exe"; see #66586.
1845
+ exe := filepath .Join (testenv .GOROOT (t ), "bin/gofmt" )
1846
+ cmd := exec .Command (exe )
1847
+ if cmd .Path != exe {
1848
+ t .Errorf ("exec.Command(%#q) set Path=%#q" , exe , cmd .Path )
1849
+ }
1850
+ err := cmd .Run ()
1851
+ if err != nil {
1852
+ t .Errorf ("using exec.Command(%#q): %v" , exe , err )
1853
+ }
1854
+
1855
+ cmd = & exec.Cmd {Path : exe }
1856
+ err = cmd .Run ()
1857
+ if err != nil {
1858
+ t .Errorf ("using exec.Cmd{Path: %#q}: %v" , cmd .Path , err )
1859
+ }
1860
+
1861
+ cmd = & exec.Cmd {Path : "gofmt" , Dir : "/" }
1862
+ err = cmd .Run ()
1863
+ if err == nil {
1864
+ t .Errorf ("using exec.Cmd{Path: %#q}: unexpected success" , cmd .Path )
1865
+ }
1866
+ }
You can’t perform that action at this time.
0 commit comments