aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/os/os_chmod_test.go
diff options
context:
space:
mode:
authorDan Kegel <[email protected]>2021-12-15 21:24:31 -0800
committerNia <[email protected]>2021-12-16 16:36:53 -0500
commit51d6ffb3bed7633faf4dd17e5b1d5eb6ad7b5bc0 (patch)
tree51483df16b5c96397e4ad7c3195fd7b2f1042541 /src/os/os_chmod_test.go
parent964aa7058aa3e9d0ad8ac32d64bba878610a112e (diff)
downloadtinygo-51d6ffb3bed7633faf4dd17e5b1d5eb6ad7b5bc0.tar.gz
tinygo-51d6ffb3bed7633faf4dd17e5b1d5eb6ad7b5bc0.zip
os: Chmod: don't test on wasi yet, wasi-libc does not yet support it
Lets "tinygo test -target wasi os" compile, if not pass. For https://github.com/tinygo-org/tinygo/issues/2369
Diffstat (limited to 'src/os/os_chmod_test.go')
-rw-r--r--src/os/os_chmod_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/os/os_chmod_test.go b/src/os/os_chmod_test.go
new file mode 100644
index 000000000..eef507c3d
--- /dev/null
+++ b/src/os/os_chmod_test.go
@@ -0,0 +1,27 @@
+// +build !baremetal,!js,!wasi
+
+// TODO: Move this into os_test.go (as upstream has it) when wasi supports chmod
+
+package os_test
+
+import (
+ . "os"
+ "runtime"
+ "testing"
+)
+
+func TestChmod(t *testing.T) {
+ f := newFile("TestChmod", t)
+ defer Remove(f.Name())
+ defer f.Close()
+ // Creation mode is read write
+
+ fm := FileMode(0456)
+ if runtime.GOOS == "windows" {
+ fm = FileMode(0444) // read-only file
+ }
+ if err := Chmod(f.Name(), fm); err != nil {
+ t.Fatalf("chmod %s %#o: %s", f.Name(), fm, err)
+ }
+ checkMode(t, f.Name(), fm)
+}