hst/fslink: improve string representation
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m7s
Test / Hakurei (push) Successful in 3m14s
Test / Hpkg (push) Successful in 4m1s
Test / Sandbox (race detector) (push) Successful in 4m29s
Test / Hakurei (race detector) (push) Successful in 5m9s
Test / Flake checks (push) Successful in 1m25s
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m7s
Test / Hakurei (push) Successful in 3m14s
Test / Hpkg (push) Successful in 4m1s
Test / Sandbox (race detector) (push) Successful in 4m29s
Test / Hakurei (race detector) (push) Successful in 5m9s
Test / Flake checks (push) Successful in 1m25s
This shortens the representation of most common use cases and generally improves readability. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
9585b35d5b
commit
c328b584c0
@ -51,8 +51,8 @@ Filesystem
|
||||
w+ephemeral(-rwxr-xr-x):/tmp/
|
||||
w*/nix/store:/mnt-root/nix/.rw-store/upper:/mnt-root/nix/.rw-store/work:/mnt-root/nix/.ro-store
|
||||
*/nix/store
|
||||
&/run/current-system:*/run/current-system
|
||||
&/run/opengl-driver:*/run/opengl-driver
|
||||
/run/current-system@
|
||||
/run/opengl-driver@
|
||||
w*/var/lib/hakurei/u0/org.chromium.Chromium:/data/data/org.chromium.Chromium
|
||||
d+/dev/dri
|
||||
|
||||
@ -128,8 +128,8 @@ Filesystem
|
||||
w+ephemeral(-rwxr-xr-x):/tmp/
|
||||
w*/nix/store:/mnt-root/nix/.rw-store/upper:/mnt-root/nix/.rw-store/work:/mnt-root/nix/.ro-store
|
||||
*/nix/store
|
||||
&/run/current-system:*/run/current-system
|
||||
&/run/opengl-driver:*/run/opengl-driver
|
||||
/run/current-system@
|
||||
/run/opengl-driver@
|
||||
w*/var/lib/hakurei/u0/org.chromium.Chromium:/data/data/org.chromium.Chromium
|
||||
d+/dev/dri
|
||||
|
||||
|
@ -50,9 +50,12 @@ func (l *FSLink) String() string {
|
||||
return "<invalid>"
|
||||
}
|
||||
|
||||
dereference := ""
|
||||
var dereference string
|
||||
if l.Dereference {
|
||||
if l.Target.String() == l.Linkname {
|
||||
return l.Target.String() + "@"
|
||||
}
|
||||
dereference = "*"
|
||||
}
|
||||
return "&" + l.Target.String() + ":" + dereference + l.Linkname
|
||||
return l.Target.String() + " -> " + dereference + l.Linkname
|
||||
}
|
||||
|
@ -12,7 +12,20 @@ func TestFSLink(t *testing.T) {
|
||||
{"nil", (*hst.FSLink)(nil), false, nil, nil, nil, "<invalid>"},
|
||||
{"zero", new(hst.FSLink), false, nil, nil, nil, "<invalid>"},
|
||||
|
||||
{"deref rel", &hst.FSLink{Target: m("/"), Linkname: ":3", Dereference: true}, false, nil, nil, nil, "<invalid>"},
|
||||
{"deref rel", &hst.FSLink{Target: m("/"), Linkname: ":3", Dereference: true},
|
||||
false, nil, nil, nil, "<invalid>"},
|
||||
{"deref differs", &hst.FSLink{
|
||||
Target: m("/.hakurei/etc"),
|
||||
Linkname: "/etc/static",
|
||||
Dereference: true,
|
||||
}, true, container.Ops{
|
||||
&container.SymlinkOp{
|
||||
Target: m("/.hakurei/etc"),
|
||||
LinkName: "/etc/static",
|
||||
Dereference: true,
|
||||
},
|
||||
}, m("/.hakurei/etc"), nil,
|
||||
"/.hakurei/etc -> */etc/static"},
|
||||
{"deref", &hst.FSLink{
|
||||
Target: m("/run/current-system"),
|
||||
Linkname: "/run/current-system",
|
||||
@ -24,7 +37,7 @@ func TestFSLink(t *testing.T) {
|
||||
Dereference: true,
|
||||
},
|
||||
}, m("/run/current-system"), nil,
|
||||
"&/run/current-system:*/run/current-system"},
|
||||
"/run/current-system@"},
|
||||
|
||||
{"direct", &hst.FSLink{
|
||||
Target: m("/etc/mtab"),
|
||||
@ -34,7 +47,7 @@ func TestFSLink(t *testing.T) {
|
||||
Target: m("/etc/mtab"),
|
||||
LinkName: "/proc/mounts",
|
||||
},
|
||||
}, m("/etc/mtab"), nil, "&/etc/mtab:/proc/mounts"},
|
||||
}, m("/etc/mtab"), nil, "/etc/mtab -> /proc/mounts"},
|
||||
|
||||
{"direct rel", &hst.FSLink{
|
||||
Target: m("/etc/mtab"),
|
||||
@ -44,6 +57,6 @@ func TestFSLink(t *testing.T) {
|
||||
Target: m("/etc/mtab"),
|
||||
LinkName: "../proc/mounts",
|
||||
},
|
||||
}, m("/etc/mtab"), nil, "&/etc/mtab:../proc/mounts"},
|
||||
}, m("/etc/mtab"), nil, "/etc/mtab -> ../proc/mounts"},
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user