Skip to content

Commit

Permalink
pkg/shell: Fix test when running as root.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaq committed Oct 4, 2024
1 parent a851906 commit 6911307
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/shell/paths_test.elvts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
▶ $true

## errors if unable to create run directory ##
// We rely on the permission bits of the parent directory to prevent creation of
// the run direction, but this doesn't work for root (who ignores the permission
// bits entirely).
//skip-if-root
~> use os
os:mkdir-all &perm=0o000 xdg_runtime_dir
set E:XDG_RUNTIME_DIR = $pwd/xdg_runtime_dir
Expand Down
5 changes: 5 additions & 0 deletions pkg/shell/transcripts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func TestTranscripts(t *testing.T) {
testutil.Umask(t, must.OK1(strconv.Atoi(arg)))
},
"in-temp-home", func(t *testing.T) { testutil.InTempHome(t) },
"skip-if-root", func(t *testing.T) {
if os.Getuid() == 0 {
t.SkipNow()
}
},
)
}

Expand Down

0 comments on commit 6911307

Please sign in to comment.