<commit_before>use std::fs::remove_file;
use std::process::{Command, Output};

const RUSTC_COLOR_ARGS: &[&str] = &["--color", "always"];

pub fn compile_test_cmd(filename: &str) -> Output {
    Command::new("rustc")
        .args(&["--test", filename, "-o", "temp"])
        .args(RUSTC_COLOR_ARGS)
        .output()
        .expect("failed to compile exercise")
}

pub fn compile_cmd(filename: &str) -> Output {
    Command::new("rustc")
        .args(&[filename, "-o", "temp"])
        .args(RUSTC_COLOR_ARGS)
        .output()
        .expect("failed to compile exercise")
}

pub fn run_cmd() -> Output {
    Command::new("./temp")
        .output()
        .expect("failed to run exercise")
}

pub fn clean() {
    let _ignored = remove_file("temp");
}

#[test]
fn test_clean() {
    std::fs::File::create("temp").unwrap();
    clean();
    assert!(!std::path::Path::new("temp").exists());
}<commit_msg>Add process id to temp file name<commit_after>use std::fs::remove_file;
use std::process::{self, Command, Output};

const RUSTC_COLOR_ARGS: &[&str] = &["--color", "always"];

fn temp_file() -> String {
    format!("./temp_{}", process::id())
}

pub fn compile_test_cmd(filename: &str) -> Output {
    Command::new("rustc")
        .args(&["--test", filename, "-o", &temp_file()])
        .args(RUSTC_COLOR_ARGS)
        .output()
        .expect("failed to compile exercise")
}

pub fn compile_cmd(filename: &str) -> Output {
    Command::new("rustc")
        .args(&[filename, "-o", &temp_file()])
        .args(RUSTC_COLOR_ARGS)
        .output()
        .expect("failed to compile exercise")
}

pub fn run_cmd() -> Output {
    Command::new(&temp_file())
        .output()
        .expect("failed to run exercise")
}

pub fn clean() {
    let _ignored = remove_file(&temp_file());
}

#[test]
fn test_clean() {
    std::fs::File::create(&temp_file()).unwrap();
    clean();
    assert!(!std::path::Path::new(&temp_file()).exists());
}
{'fraction_non_alphanumeric': 0.20638188368502317, 'fraction_numerical': 0.0, 'mean_word_length': 3.32, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1396196', 'n_tokens_mistral': 652, 'n_tokens_neox': 657, 'n_words': 138}