File: chmod.go

package info (click to toggle)
elvish 0.21.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,372 kB
  • sloc: javascript: 236; sh: 130; python: 104; makefile: 88; xml: 9
file content (22 lines) | stat: -rw-r--r-- 453 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package testutil

import (
	"io/fs"
	"os"
)

// ChmodOrSkip runs [os.Chmod], but skips the test if file's mode is not exactly
// mode or if there is any error.
func ChmodOrSkip(s Skipper, name string, mode fs.FileMode) {
	err := os.Chmod(name, mode)
	if err != nil {
		s.Skipf("chmod: %v", err)
	}
	fi, err := os.Stat(name)
	if err != nil {
		s.Skipf("stat: %v", err)
	}
	if fi.Mode() != mode {
		s.Skipf("file mode %O is not %O", fi.Mode(), mode)
	}
}