Format the read-only bundle regression test
This commit is contained in:
+19
-4
@@ -105,21 +105,36 @@ fn readonly_bundle_copies_are_writable() -> std::io::Result<()> {
|
||||
fs::write(&path, b"original")?;
|
||||
fs::set_permissions(path, fs::Permissions::from_mode(mode))?;
|
||||
}
|
||||
for path in [bundle.path().join("bin"), bundle.path().join("src"), bundle.path().to_owned(), world.path().to_owned()] {
|
||||
for path in [
|
||||
bundle.path().join("bin"),
|
||||
bundle.path().join("src"),
|
||||
bundle.path().to_owned(),
|
||||
world.path().to_owned(),
|
||||
] {
|
||||
fs::set_permissions(path, fs::Permissions::from_mode(0o555))?;
|
||||
}
|
||||
let result = copy_tree(bundle.path(), world.path());
|
||||
// Restore source directories so the temporary directory can remove its files.
|
||||
for path in [bundle.path(), &bundle.path().join("bin"), &bundle.path().join("src")] {
|
||||
for path in [
|
||||
bundle.path(),
|
||||
&bundle.path().join("bin"),
|
||||
&bundle.path().join("src"),
|
||||
] {
|
||||
fs::set_permissions(path, fs::Permissions::from_mode(0o755))?;
|
||||
}
|
||||
result?;
|
||||
assert_eq!(fs::metadata(world.path())?.permissions().mode() & 0o777, 0o755);
|
||||
assert_eq!(
|
||||
fs::metadata(world.path())?.permissions().mode() & 0o777,
|
||||
0o755
|
||||
);
|
||||
for (name, mode) in [("bin/tool.wasm", 0o555), ("src/lib.rs", 0o444)] {
|
||||
let source = bundle.path().join(name);
|
||||
let target = world.path().join(name);
|
||||
assert_eq!(fs::metadata(&source)?.permissions().mode() & 0o777, mode);
|
||||
assert_eq!(fs::metadata(&target)?.permissions().mode() & 0o777, mode | 0o200);
|
||||
assert_eq!(
|
||||
fs::metadata(&target)?.permissions().mode() & 0o777,
|
||||
mode | 0o200
|
||||
);
|
||||
fs::write(&target, b"changed")?;
|
||||
assert_eq!(fs::read(source)?, b"original");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user