Open Mte90 opened 1 month ago
using trap
command is important, folder should be deleted also if script fail
pub fun run_in_tmp(): Null {
if(not shell_isset("CURRENT_TMP_DIR")) {
$cd \$(mktemp -d /tmp/XXXXXX)$ failed {
error("Failed to create temp folder")
exit(1)
}
let tmp_dir = unsafe $pwd$
unsafe shell_constant_set("CURRENT_TMP_DIR", tmp_dir)
unsafe $trap "rm -Rf \$CURRENT_TMP_DIR" EXIT$
} else {
unsafe $cd \$CURRENT_TMP_DIR$
}
}
In this way they are sandboxed (I execute them on my machine I dont want to have issues).
Following @CymDeveloppement proposal we can do something like:
An idea can be on Rust side create that folder, execute the script inside that and remove it when finished. So we don't need to modify any test.