mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-13 23:43:40 +00:00
src/os: Add UserHomeDir() function to os package
This commit adds the `UserHomeDir()` function to the `os` package.
This commit is contained in:
@@ -253,3 +253,21 @@ func TestRenameFailed(t *testing.T) {
|
||||
t.Errorf("rename %q, %q: expected %T, got %T %v", from, to, new(LinkError), err, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUserHomeDir(t *testing.T) {
|
||||
dir, err := UserHomeDir()
|
||||
if dir == "" && err == nil {
|
||||
t.Fatal("UserHomeDir returned an empty string but no error")
|
||||
}
|
||||
if err != nil {
|
||||
t.Logf("UserHomeDir failed: %v", err)
|
||||
return
|
||||
}
|
||||
fi, err := Stat(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !fi.IsDir() {
|
||||
t.Fatalf("dir %s is not directory; type = %v", dir, fi.Mode())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user