mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-19 12:04:03 +00:00
os.Stat: returned error on nonexistent path did not satisfy IsNotExist
Add direct test for the problem to make the fix commit clearer. Noticed while implementing MkdirTemp on mac; the upstream tests for MkdirTemp fail without this.
This commit is contained in:
@@ -4,6 +4,7 @@ package os_test
|
||||
|
||||
import (
|
||||
. "os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -31,6 +32,16 @@ func TestMkdir(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatBadDir(t *testing.T) {
|
||||
dir := TempDir()
|
||||
badDir := filepath.Join(dir, "not-exist/really-not-exist")
|
||||
_, err := Stat(badDir)
|
||||
// TODO: PathError moved to io/fs in go 1.16; fix next line once we drop go 1.15 support.
|
||||
if pe, ok := err.(*PathError); !ok || !IsNotExist(err) || pe.Path != badDir {
|
||||
t.Errorf("Mkdir error = %#v; want PathError for path %q satisifying IsNotExist", err, badDir)
|
||||
}
|
||||
}
|
||||
|
||||
func writeFile(t *testing.T, fname string, flag int, text string) string {
|
||||
f, err := OpenFile(fname, flag, 0666)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user