|
|
@@ -441,3 +441,45 @@ mod solo_tests;
|
|
|
|
|
|
#[path = "sglang_tests.rs"]
|
|
|
mod sglang_tests;
|
|
|
+
|
|
|
+/// Symlinks in a build context (upstream repos may link a directory, e.g.
|
|
|
+/// `vllm -> .submodules/spark-agent/vllm`) must not be dereferenced: reading
|
|
|
+/// one as a file returns EISDIR and killed `sm121 build` before the first
|
|
|
+/// byte. They hash as their dotted target text instead — the upload tar
|
|
|
+/// dereferences separately (`tar --dereference`), so the digest tracks the
|
|
|
+/// tree shape, not the copied bytes.
|
|
|
+#[test]
|
|
|
+fn dir_checksum_hashes_symlinks_by_target_text() {
|
|
|
+ use super::build_dir::compute_dir_checksum;
|
|
|
+
|
|
|
+ let root = std::env::temp_dir().join(format!(
|
|
|
+ "sm121-chksum-link-{}",
|
|
|
+ std::process::id()
|
|
|
+ ));
|
|
|
+ let dir = root.join("ctx");
|
|
|
+ let _ = std::fs::remove_dir_all(&root);
|
|
|
+ // Linked target lives OUTSIDE the hashed tree (like an upstream submodule
|
|
|
+ // checkout outside the build context's flattened Docker view).
|
|
|
+ std::fs::create_dir_all(root.join("linked")).unwrap();
|
|
|
+ std::fs::write(root.join("linked/status-server.py"), b"# py").unwrap();
|
|
|
+ std::fs::create_dir_all(&dir).unwrap();
|
|
|
+ std::fs::write(dir.join("top.txt"), b"top").unwrap();
|
|
|
+ std::os::unix::fs::symlink("../linked", dir.join("vllm")).unwrap();
|
|
|
+
|
|
|
+ // Regression: previously File::open on the directory link -> EISDIR.
|
|
|
+ let first = compute_dir_checksum(&dir).unwrap();
|
|
|
+ assert_eq!(first, compute_dir_checksum(&dir).unwrap(), "deterministic");
|
|
|
+
|
|
|
+ // The target lives outside and is never followed: edits there do not
|
|
|
+ // move the digest.
|
|
|
+ std::fs::write(root.join("linked/status-server.py"), b"# changed")
|
|
|
+ .unwrap();
|
|
|
+ assert_eq!(first, compute_dir_checksum(&dir).unwrap());
|
|
|
+
|
|
|
+ // The link's own text is part of the digest: retarget -> different hash.
|
|
|
+ std::fs::remove_file(dir.join("vllm")).unwrap();
|
|
|
+ std::os::unix::fs::symlink("../top.txt", dir.join("vllm")).unwrap();
|
|
|
+ assert_ne!(first, compute_dir_checksum(&dir).unwrap());
|
|
|
+
|
|
|
+ let _ = std::fs::remove_dir_all(&root);
|
|
|
+}
|