mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-11-27 23:11:20 +08:00
607fa68aca
Time fields are omitted for now; they will be added when there's a proper Elvish binding for time.Time. This addresses #1659.
23 lines
453 B
Go
23 lines
453 B
Go
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)
|
|
}
|
|
}
|