Skip to content

Commit 2291cf3

Browse files
committed
Fix rust compilation
When using rustup, rustc is a symlink: we must not change the binary name using canonicalize.
1 parent 97b0758 commit 2291cf3

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
22
channel = "1.88"
3-
components = [ "rustfmt", "clippy" ]
3+
components = [ "rustfmt", "clippy", "rust-analyzer" ]

task-maker-exec/src/execution_unit/sandbox.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,9 @@ impl Sandbox {
391391
ExecutionCommand::System(cmd) => {
392392
if let Ok(cmd) = which::which(cmd) {
393393
// Always mount the directory with the executable.
394-
let cmd = std::fs::canonicalize(cmd).context("Failed to canonicalize path")?;
395-
let path = cmd.parent().expect("invalid binary path");
394+
let path =
395+
std::fs::canonicalize(&cmd).context("Failed to canonicalize path")?;
396+
let path = path.parent().expect("invalid binary path");
396397
if !mounted_dirs.contains(path) {
397398
config.mount(path, path, false);
398399
mounted_dirs.insert(path);
@@ -646,10 +647,7 @@ mod tests {
646647
assert_eq!(config.stdin, Some("/dev/null".into()));
647648
assert_eq!(config.stdout, Some("/dev/null".into()));
648649
assert_eq!(config.stderr, Some("/dev/null".into()));
649-
assert_eq!(
650-
config.executable,
651-
std::fs::canonicalize(Path::new("/bin/sh")).unwrap()
652-
);
650+
assert_eq!(config.executable, Path::new("/bin/sh"));
653651
assert_eq!(config.args, vec!["bar", "baz"]);
654652
}
655653
}

tests/classic.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fn classic(test: TestInterface) {
1818
.must_compile("tle.cpp")
1919
.must_compile("wa.cpp")
2020
.must_compile("wrong_file.cpp")
21+
.must_compile("rust.rs")
2122
.must_not_compile("not_compile.cpp")
2223
// .not_compiled(".ignoreme.cpp")
2324
.not_compiled("bash.sh")
@@ -33,6 +34,7 @@ fn classic(test: TestInterface) {
3334
.solution_score("tle.cpp", vec![5.0, 45.0, 0.0])
3435
.solution_score("wa.cpp", vec![0.0, 0.0, 0.0])
3536
.solution_score("wrong_file.cpp", vec![0.0, 0.0, 0.0])
37+
.solution_score("rust.rs", vec![5.0, 45.0, 50.0])
3638
.solution_statuses("soluzione.py", vec![Accepted("Output is correct".into())])
3739
.solution_statuses("bash.sh", vec![Accepted("Output is correct".into())])
3840
// .solution_statuses("mle.cpp", vec![RuntimeError]) // pretty unreliable

0 commit comments

Comments
 (0)