Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,16 @@ mod tests {
fn test_canonicalize_rootfs() {
let rootfs_name = "rootfs";
let bundle = tempfile::tempdir().expect("failed to create tmp test bundle dir");
let rootfs_absolute_path = bundle.path().join(rootfs_name);

// On macOS, `$TMPDIR` may not point to canonicalized path.
// ```
// $ echo $TMPDIR; realpath $TMPDIR
// /var/folders/_h/j_17023n23s3_50cq_gwhrrc0000gq/T/
// /private/var/folders/_h/j_17023n23s3_50cq_gwhrrc0000gq/T
// ```
let bundle = fs::canonicalize(bundle.path()).expect("failed to canonicalize bundle");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why macOS needs fs::canonicalize().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ echo $TMPDIR; realpath $TMPDIR
/var/folders/_h/j_17023n23s3_50cq_gwhrrc0000gq/T/
/private/var/folders/_h/j_17023n23s3_50cq_gwhrrc0000gq/T

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask you to add the comment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


let rootfs_absolute_path = bundle.join(rootfs_name);
assert!(
rootfs_absolute_path.is_absolute(),
"rootfs path is not absolute path"
Expand All @@ -295,7 +304,7 @@ mod tests {
.build()
.unwrap();

spec.canonicalize_rootfs(bundle.path())
spec.canonicalize_rootfs(&bundle)
.expect("failed to canonicalize rootfs");

assert_eq!(
Expand All @@ -310,7 +319,7 @@ mod tests {
.build()
.unwrap();

spec.canonicalize_rootfs(bundle.path())
spec.canonicalize_rootfs(&bundle)
.expect("failed to canonicalize rootfs");

assert_eq!(
Expand Down
Loading