diff --git a/.github/workflows/release-test.yml b/.github/workflows/release-test.yml deleted file mode 100644 index cafaf06da..000000000 --- a/.github/workflows/release-test.yml +++ /dev/null @@ -1,54 +0,0 @@ -# Testing the release process is a nasty process since release.yml is triggered -# when a release is created. Creating a release will send an email to all the -# users watching the repo. To avoid spamming those uses with "test releases" we -# can manually trigger the build process and simply avoid publishing the -# release. - -name: Manual Release Test - -on: workflow_dispatch - -jobs: - deb: - name: Debian/Ubuntu (deb) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Build deb file - run: | - docker run --rm -v $(pwd):/source ghcr.io/edomora97/task-maker-rust-release-linux - - name: Upload the artifacts - uses: actions/upload-artifact@v4 - with: - name: Ubuntu deb - path: "target/debian/*.deb" - - aur: - name: AUR - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Build PKGBUILD - working-directory: tools/aur/task-maker-rust - run: ./gen.sh > ../../../PKGBUILD - ## Commented out since it doesn't support dry-run. - # - name: Publish PKGBUILD - # uses: KSXGitHub/github-actions-deploy-aur@v2.7.0 - # with: - # pkgname: task-maker-rust - # pkgbuild: ./PKGBUILD - # commit_username: ${{ secrets.AUR_USERNAME }} - # commit_email: ${{ secrets.AUR_EMAIL }} - # ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} - - # Do not trigger the PPA rebuilding for this test. - # ppa: - # name: Publish PPA - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - name: Trigger PPA build - # env: - # GH_TOKEN: ${{ secrets.PAT_PPA_ACTION_TRIGGER }} - # run: | - # gh workflow run -R dp1/task-maker-rust-ppa --ref master check-for-release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fb2505323..d89043363 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,36 +1,67 @@ name: Release on: + workflow_dispatch: release: types: [created] jobs: deb: - name: Debian/Ubuntu (deb) + name: Create deb packages runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + os: + - ubuntu:25.04 + - ubuntu:24.10 + - ubuntu:24.04 + - ubuntu:22.04 + - debian:bullseye + - debian:bookworm + - debian:trixie + container: + image: ${{ matrix.os }} steps: - uses: actions/checkout@v4 + - name: Install Deps + run: | + apt update + apt install -yy libseccomp-dev build-essential fpc + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + id: install-rust + - name: Install cargo-deb + run: cargo install cargo-deb + + - name: Calculate artifact suffix + shell: python3 {0} + run: | + import os + artifact_suffix="${{ matrix.os }}".replace(':', '-') + open(os.getenv("GITHUB_ENV"), "a").write(f"ARTIFACT_SUFFIX={artifact_suffix}\n") + + - name: Release build + run: cargo build --release + + - name: Generate autocompletion files + run: target/release/task-maker-tools gen-autocompletion + - name: Build deb file + run: cargo deb + + - name: Package release tarball run: | - docker run --rm -v $(pwd):/source ghcr.io/edomora97/task-maker-rust-release-linux - - name: Upload the artifacts - uses: skx/github-action-publish-binaries@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ROOT=`pwd` + cd target/debian/ + tar -zcvf ${ROOT}/tmr-debs-${{ env.ARTIFACT_SUFFIX }}.tar.gz *task-maker-rust*.* + + - name: Upload release tarball + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: - args: "target/debian/*.deb" - ## For now do not build the docker container for the server/worker: it requires some fixes because the workers - ## now spawn a single instance instead of as many as cores. Moreover, the server and worker commands changed. - # - name: Publish docker container - # run: | - # echo ${DOCKER_PASSWORD} | docker login --username edomora97 --password-stdin - # export TM_VERSION=$(grep version Cargo.toml | head -n 1 | cut -d'"' -f 2) - # cd tools/docker - # docker build --build-arg TM_VERSION=$TM_VERSION -t edomora97/task-maker-rust:latest -t edomora97/task-maker-rust:$TM_VERSION . - # docker push edomora97/task-maker-rust:$TM_VERSION - # docker push edomora97/task-maker-rust:latest - # env: - # DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + name: tmr-debs-${{ env.ARTIFACT_SUFFIX }} + path: tmr-debs-${{ env.ARTIFACT_SUFFIX }}.tar.gz + compression-level: 0 aur: name: AUR @@ -41,6 +72,7 @@ jobs: working-directory: tools/aur/task-maker-rust run: ./gen.sh > ../../../PKGBUILD - name: Publish PKGBUILD + if: ${{ github.event_name == 'release' }} # skip on manual runs. uses: KSXGitHub/github-actions-deploy-aur@v4.1.1 with: pkgname: task-maker-rust @@ -48,14 +80,3 @@ jobs: commit_username: ${{ secrets.AUR_USERNAME }} commit_email: ${{ secrets.AUR_EMAIL }} ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} - - ppa: - name: Publish PPA - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Trigger PPA build - env: - GH_TOKEN: ${{ secrets.PAT_PPA_ACTION_TRIGGER }} - run: | - gh workflow run -R dp1/task-maker-rust-ppa --ref master check-for-release.yml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 800092935..863fbde33 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -58,11 +58,3 @@ jobs: - name: cargo fmt run: cargo fmt --all -- --check - - cargo-lock-3: - name: Check cargo lock version = 3 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: check - run: grep "version = 3" Cargo.lock > /dev/null diff --git a/README.md b/README.md index daf3ebee7..3c079247e 100644 --- a/README.md +++ b/README.md @@ -7,18 +7,16 @@ The new cmsMake! [![asciicast](https://asciinema.org/a/301849.svg)](https://asciinema.org/a/301849) ## Installation -For **Ubuntu** and **Debian** users you can find the `.deb` file in the [Releases](https://github.com/olimpiadi-informatica/task-maker-rust/releases) page. -Install the package using `sudo dpkg -i the_file.deb` and it's dependencies (if you need to) with `sudo apt install -f`. -There is a good chance that you have already all the dependencies already installed. - -For **Ubuntu** it's also possible to install task-maker-rust using a PPA: +For **Ubuntu** and **Debian** users, you can install this package as follows: ```bash -sudo add-apt-repository ppa:dariop1/task-maker-rust -sudo apt update -sudo apt install task-maker-rust +echo "deb [signed-by=/etc/apt/keyrings/task-maker-rust.asc] https://artifacts.lucaversari.it/olimpiadi-informatica/task-maker-rust/latest/deb/$(lsb_release -cs) /" | sudo tee /etc/apt/sources.list.d/task-maker-rust.list +curl https://artifacts.lucaversari.it/signing-key.asc | sudo tee /etc/apt/keyrings/task-maker-rust.asc > /dev/null +sudo apt update && sudo apt install task-maker-rust ``` +You can also find the `.deb` files in the [Releases](https://github.com/olimpiadi-informatica/task-maker-rust/releases) page. + For **ArchLinux** users you can find the packages in the AUR: [`task-maker-rust`](https://aur.archlinux.org/packages/task-maker-rust) (the stable release) and [`task-maker-rust-git`](https://aur.archlinux.org/packages/task-maker-rust-git) (the version based on `master`). diff --git a/build.rs b/build.rs index 40967b0a3..a4b96e360 100644 --- a/build.rs +++ b/build.rs @@ -18,7 +18,7 @@ fn get_version() -> String { if from_git.is_empty() { version } else { - format!("{}\n\nRevision: {}", version, from_git) + format!("{version}\n\nRevision: {from_git}") } } Err(_) => version, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 96c1b3eb5..13a8515e6 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.75" +channel = "1.88" components = [ "rustfmt", "clippy" ] diff --git a/src/copy_dag.rs b/src/copy_dag.rs index a1924e5ef..e6e4a308b 100644 --- a/src/copy_dag.rs +++ b/src/copy_dag.rs @@ -49,7 +49,7 @@ pub fn render_dag(dag: &ExecutionDAG) -> String { for exec in &group.executions { for dep in exec.dependencies() { if !files.contains_key(&dep) { - panic!("Nope: {:#?} does not contain {:?}", exec, dep); + panic!("Nope: {exec:#?} does not contain {dep:?}"); } let file = &files[&dep]; edges.push((Node::File(file.clone()), Node::Execution(exec.clone()))); diff --git a/src/error.rs b/src/error.rs index b8fbfb6be..a5a47acc7 100644 --- a/src/error.rs +++ b/src/error.rs @@ -18,9 +18,9 @@ pub trait NiceError { fn print_error(error: Error) { debug!("{:?}", error); let mut fail: &dyn std::error::Error = error.as_ref(); - eprintln!("Error: {}", fail); + eprintln!("Error: {fail}"); while let Some(cause) = fail.source() { - eprintln!("\nCaused by:\n {}", cause); + eprintln!("\nCaused by:\n {cause}"); fail = cause; } } diff --git a/src/sandbox.rs b/src/sandbox.rs index a2538ac8a..b6fc9866d 100644 --- a/src/sandbox.rs +++ b/src/sandbox.rs @@ -32,7 +32,7 @@ pub fn main_sandbox() { .expect("Failed to print result"); } Err(e) => { - let err = format!("Error: {:?}", e); + let err = format!("Error: {e:?}"); serde_json::to_writer(stdout(), &RawSandboxResult::Error(err)) .expect("Failed to print result"); } diff --git a/src/tools/add_solution_checks.rs b/src/tools/add_solution_checks.rs index 08eb1ce73..a00efc0c1 100644 --- a/src/tools/add_solution_checks.rs +++ b/src/tools/add_solution_checks.rs @@ -214,7 +214,7 @@ fn process_solution( ) }) { - eprintln!("Error: {:?}", e); + eprintln!("Error: {e:?}"); } else { written = " (written!)"; } diff --git a/src/tools/find_bad_case/curses_ui.rs b/src/tools/find_bad_case/curses_ui.rs index b03228574..4f96adb34 100644 --- a/src/tools/find_bad_case/curses_ui.rs +++ b/src/tools/find_bad_case/curses_ui.rs @@ -116,7 +116,7 @@ impl CursesUI { let mut line = Vec::new(); let batch_index = state.batches.len() - 1 - i; let batch = &state.batches[state.batches.len() - 1 - i]; - line.push(Span::raw(format!("Batch {:>3}: ", batch_index))); + line.push(Span::raw(format!("Batch {batch_index:>3}: "))); line.extend( batch .testcase_status diff --git a/src/tools/find_bad_case/dag.rs b/src/tools/find_bad_case/dag.rs index 5822557b6..7bf72b042 100644 --- a/src/tools/find_bad_case/dag.rs +++ b/src/tools/find_bad_case/dag.rs @@ -80,10 +80,10 @@ pub fn patch_task_for_batch( let data = TestcaseData { generator_args, seed, - input_path: working_directory.join(format!("testcase-{}/input.txt", seed)), - output_path: working_directory.join(format!("testcase-{}/output.txt", seed)), + input_path: working_directory.join(format!("testcase-{seed}/input.txt")), + output_path: working_directory.join(format!("testcase-{seed}/output.txt")), correct_output_path: working_directory - .join(format!("testcase-{}/correct_output.txt", seed)), + .join(format!("testcase-{seed}/correct_output.txt")), }; testcases.insert(testcase_id, testcase); @@ -91,7 +91,7 @@ pub fn patch_task_for_batch( } let subtask = SubtaskInfo { id: 0, - name: Some(format!("batch-{}", batch_index)), + name: Some(format!("batch-{batch_index}")), max_score: 100.0, testcases: testcases.keys().cloned().collect(), testcases_owned: testcases.keys().cloned().collect(), diff --git a/src/tools/find_bad_case/mod.rs b/src/tools/find_bad_case/mod.rs index 11785bdba..1964d5cf3 100644 --- a/src/tools/find_bad_case/mod.rs +++ b/src/tools/find_bad_case/mod.rs @@ -234,7 +234,7 @@ pub fn main_find_bad_case(opt: FindBadCaseOpt) -> Result<(), Error> { cwrite!(printer, BOLD, " Seed: "); println!("{}", testcase.seed); cwrite!(printer, BOLD, " Message: "); - println!("{}", message); + println!("{message}"); println!(); print_file("Input file", &task_path, &input_path, &mut printer)?; if let Some(correct_output_path) = correct_output_path { @@ -342,7 +342,7 @@ fn print_failures(shared: &SharedUIState, printer: &mut StdoutPrinter) { if let Some((testcase, message, result)) = &shared.errored_testcase { println!(); cwrite!(printer, RED, "Error: "); - println!("{}", message); + println!("{message}"); cwrite!(printer, BOLD, "Generator args: "); println!("{}", testcase.generator_args.join(" ")); cwrite!(printer, BOLD, "Result: "); diff --git a/src/tools/fuzz_checker.rs b/src/tools/fuzz_checker.rs index 23ae44411..733c5ce46 100644 --- a/src/tools/fuzz_checker.rs +++ b/src/tools/fuzz_checker.rs @@ -126,7 +126,7 @@ pub fn main_fuzz_checker(opt: FuzzCheckerOpt) -> Result<(), Error> { let fuzz_data = FuzzData { checker_source: checker.path.clone(), initial_output_files: (0..num_testcases) - .map(|i| task_dir.join(format!("output/output{}.txt", i))) + .map(|i| task_dir.join(format!("output/output{i}.txt"))) .collect(), task_dir, opt, @@ -192,7 +192,7 @@ fn write_initial_corpus(fuzz_dir: &Path, data: &FuzzData) -> Result<(), Error> { } for (index, output) in data.initial_output_files.iter().enumerate() { - let path = initial_corpus_dir.join(format!("{}.txt", index)); + let path = initial_corpus_dir.join(format!("{index}.txt")); if path.exists() { debug!("Removing old corpus at {}", path.display()); std::fs::remove_file(&path) @@ -380,7 +380,7 @@ fn compile_fuzzer( command.arg(sanitizers); let std_version = std::env::var("TM_CXX_STD_VERSION").unwrap_or_else(|_| "c++17".into()); - command.arg(format!("-std={}", std_version)); + command.arg(format!("-std={std_version}")); if data.opt.extra_args.is_empty() { debug!("Adding -O2 and -g since no extra argument has been specified"); @@ -465,7 +465,7 @@ fn run_fuzzer(fuzz_dir: &Path, data: &FuzzData, fuzzer: &Path) -> Result Result<(), Error> { let info = task.task_info().context("Cannot produce task info")?; if opt.json { let json = serde_json::to_string(&info).context("Non-serializable task info")?; - println!("{}", json); + println!("{json}"); } else { - println!("{:#?} ", info); + println!("{info:#?} "); } Ok(()) } diff --git a/src/tools/terry_statement.rs b/src/tools/terry_statement.rs index 12024739b..db61e5751 100644 --- a/src/tools/terry_statement.rs +++ b/src/tools/terry_statement.rs @@ -89,7 +89,7 @@ pub fn main_terry_statement(opt: TerryStatementOpt, _logger_opt: LoggerOpt) -> R match output_path { Some(output_file) => fs::write(output_file, new_content)?, - None => print!("{}", new_content), + None => print!("{new_content}"), } Ok(()) diff --git a/src/tools/worker.rs b/src/tools/worker.rs index caa959027..8a4eed381 100644 --- a/src/tools/worker.rs +++ b/src/tools/worker.rs @@ -66,7 +66,7 @@ pub fn main_worker(opt: WorkerOpt) -> Result<(), Error> { } let name = if let Some(wid) = opt.worker_id { - format!("{} {}", name, wid) + format!("{name} {wid}") } else { name }; diff --git a/task-maker-cache/src/key.rs b/task-maker-cache/src/key.rs index af64a5101..6440b31ed 100644 --- a/task-maker-cache/src/key.rs +++ b/task-maker-cache/src/key.rs @@ -52,7 +52,7 @@ impl CacheKeyItem { let mut fifos = HashMap::new(); for (i, fifo) in group.fifo.iter().enumerate() { let name = fifo.sandbox_path().to_string_lossy().to_string(); - fifos.insert(name, format!("tm_fifo_{}", i)); + fifos.insert(name, format!("tm_fifo_{i}")); } let mut args = Vec::new(); for arg in &execution.args { diff --git a/task-maker-diagnostics/src/lib.rs b/task-maker-diagnostics/src/lib.rs index a84ec0192..92a107e01 100644 --- a/task-maker-diagnostics/src/lib.rs +++ b/task-maker-diagnostics/src/lib.rs @@ -130,7 +130,7 @@ impl Diagnostic { write!(f, "{:>pad$}: ", "Note".bold(), pad = pad)?; let mut lines = note.lines(); if let Some(line) = lines.next() { - writeln!(f, "{}", line)?; + writeln!(f, "{line}")?; } for line in lines { writeln!(f, "{:>pad$} {}", "", line, pad = pad)?; diff --git a/task-maker-exec/src/check_dag.rs b/task-maker-exec/src/check_dag.rs index 33a6118a9..17911bc8c 100644 --- a/task-maker-exec/src/check_dag.rs +++ b/task-maker-exec/src/check_dag.rs @@ -143,8 +143,7 @@ pub fn check_dag(dag: &ExecutionDAGData, callbacks: &ExecutionDAGWatchSet) -> Re .expect("num_dependencies of an unknown execution group"); assert_ne!( *num_deps, 0, - "num_dependencies is going to be negative for {}", - group_uuid + "num_dependencies is going to be negative for {group_uuid}" ); *num_deps -= 1; if *num_deps == 0 { diff --git a/task-maker-exec/src/client.rs b/task-maker-exec/src/client.rs index dd4a4a883..8f1238068 100644 --- a/task-maker-exec/src/client.rs +++ b/task-maker-exec/src/client.rs @@ -107,7 +107,7 @@ impl ExecutorClient { .map_err(|_| anyhow!("Failed to obtain file_mode lock"))?; let provided_files = &dag.data.provided_files; handle_server_ask_file(uuid, provided_files, &sender).with_context(|| { - format!("Failed to process AskFile({}) from the server", uuid) + format!("Failed to process AskFile({uuid}) from the server") })?; } Ok(ExecutorServerMessage::ProvideFile(uuid, success)) => { @@ -119,8 +119,7 @@ impl ExecutorClient { process_provided_file(dag.file_callbacks(), uuid, success, iterator, None) .with_context(|| { format!( - "Failed to process ProvideFile({}, {}) from the server", - uuid, success + "Failed to process ProvideFile({uuid}, {success}) from the server" ) })?; } @@ -177,8 +176,7 @@ impl ExecutorClient { let iterator = ReadFileIterator::new(handle.path()).with_context(|| { format!( - "Failed to read produced file ({}) from the local storage", - handle + "Failed to read produced file ({handle}) from the local storage" ) })?; process_provided_file( @@ -190,15 +188,14 @@ impl ExecutorClient { ) .with_context(|| { format!( - "Failed to process produced file ({}) from the local storage", - handle + "Failed to process produced file ({handle}) from the local storage" ) })?; } else { sender .send(ExecutorClientMessage::AskFile(uuid, key, success)) .with_context(|| { - format!("Failed to ask for a completed file ({})", uuid) + format!("Failed to ask for a completed file ({uuid})") })?; missing += 1; } @@ -445,7 +442,7 @@ fn process_provided_file>>( if let Some(get_content) = callback.get_content.take().map(|(_, f)| f) { get_content(buffer) - .with_context(|| format!("get_content callback for file {} failed", uuid))?; + .with_context(|| format!("get_content callback for file {uuid} failed"))?; } } else { iterator.into_iter().last(); diff --git a/task-maker-exec/src/executor.rs b/task-maker-exec/src/executor.rs index 2d3bab6d2..99dc5dfad 100644 --- a/task-maker-exec/src/executor.rs +++ b/task-maker-exec/src/executor.rs @@ -362,7 +362,7 @@ impl Executor { } else { sender .send(ExecutorServerMessage::AskFile(*uuid)) - .with_context(|| format!("Failed to send AskFile({})", uuid))?; + .with_context(|| format!("Failed to send AskFile({uuid})"))?; } } // tell the scheduler that a new DAG is ready to be executed. @@ -396,7 +396,7 @@ impl Executor { let handle = file_store .store(&key, ChannelFileIterator::new(&receiver)) .with_context(|| { - format!("Failed to store client provided file {} ({})", uuid, key) + format!("Failed to store client provided file {uuid} ({key})") })?; scheduler .as_ref() @@ -417,13 +417,12 @@ impl Executor { .send(ExecutorServerMessage::ProvideFile(uuid, success)) .context("Failed to send ProvideFile to the client")?; ChannelFileSender::send(handle.path(), &sender).with_context(|| { - format!("Failed to send file {} to the client", handle) + format!("Failed to send file {handle} to the client") })?; } else { sender .send(ExecutorServerMessage::Error(format!( - "Unknown file {:?}", - key + "Unknown file {key:?}" ))) .context("Failed to send Error to the client")?; } diff --git a/task-maker-exec/src/executors/local_executor.rs b/task-maker-exec/src/executors/local_executor.rs index 22e902bfc..f5e005912 100644 --- a/task-maker-exec/src/executors/local_executor.rs +++ b/task-maker-exec/src/executors/local_executor.rs @@ -54,7 +54,7 @@ impl LocalExecutor { for i in 0..num_workers { let runner = sandbox_runner.clone(); let (worker, conn) = Worker::new( - format!("Local worker {}", i), + format!("Local worker {i}"), file_store.clone(), #[allow(clippy::needless_borrow)] &sandbox_path, @@ -64,7 +64,7 @@ impl LocalExecutor { executor_tx .send(ExecutorInMessage::WorkerConnected { worker: conn }) .map_err(|e| anyhow!("Failed to send WorkerConnected: {:?}", e))?; - let worker_name = format!("Worker {}", worker); + let worker_name = format!("Worker {worker}"); workers.push( thread::Builder::new() .name(worker_name.clone()) diff --git a/task-maker-exec/src/executors/remote_executor.rs b/task-maker-exec/src/executors/remote_executor.rs index 1c5edb6af..7d08805ef 100644 --- a/task-maker-exec/src/executors/remote_executor.rs +++ b/task-maker-exec/src/executors/remote_executor.rs @@ -96,7 +96,7 @@ impl RemoteExecutor { ) -> Result<(), Error> { let server = if let Some(path) = bind_client_addr.strip_prefix("unix://") { ChannelServer::bind_unix(path) - .with_context(|| format!("Failed to bind client unix socket at {}", path))? + .with_context(|| format!("Failed to bind client unix socket at {path}"))? } else { match client_password { Some(password) => { @@ -115,7 +115,7 @@ impl RemoteExecutor { info!( "Accepting client connections at {}", if let Some(addr) = local_addr { - format!("tcp://{}", addr) + format!("tcp://{addr}") } else { bind_client_addr } @@ -157,7 +157,7 @@ impl RemoteExecutor { ) -> Result<(), Error> { let server = if let Some(path) = bind_worker_addr.strip_prefix("unix://") { ChannelServer::bind_unix(path) - .with_context(|| format!("Failed to bind worker unix socket at {}", path))? + .with_context(|| format!("Failed to bind worker unix socket at {path}"))? } else { match worker_password { Some(password) => { @@ -175,7 +175,7 @@ impl RemoteExecutor { info!( "Accepting worker connections at {}", if let Some(addr) = local_addr { - format!("tcp://{}", addr) + format!("tcp://{addr}") } else { bind_worker_addr } @@ -225,8 +225,7 @@ fn validate_welcome( client, name, addr, version, VERSION ); let _ = sender.send(RemoteEntityMessageResponse::Rejected(format!( - "Wrong task-maker version, you have {}, server has {}", - version, VERSION + "Wrong task-maker version, you have {version}, server has {VERSION}" ))); false } else { diff --git a/task-maker-exec/src/sandbox.rs b/task-maker-exec/src/sandbox.rs index c081987fc..84450a67d 100644 --- a/task-maker-exec/src/sandbox.rs +++ b/task-maker-exec/src/sandbox.rs @@ -154,7 +154,7 @@ impl Sandbox { let raw_result = runner.run(config.build(), pid); if keep { let target = boxdir.join("result.txt"); - std::fs::write(&target, format!("{:#?}", raw_result)) + std::fs::write(&target, format!("{raw_result:#?}")) .with_context(|| format!("Failed to write {}", target.display()))?; } @@ -249,7 +249,7 @@ impl Sandbox { if let Ok(()) = self.build_command(&path, &data.execution, &mut config, data.fifo_dir.clone()) { - std::fs::write(path.join("tabox.txt"), format!("{:#?}\n", config)) + std::fs::write(path.join("tabox.txt"), format!("{config:#?}\n")) .context("Cannot write command info inside sandbox")?; } Ok(()) diff --git a/task-maker-exec/src/scheduler.rs b/task-maker-exec/src/scheduler.rs index c042ac111..7304f6d05 100644 --- a/task-maker-exec/src/scheduler.rs +++ b/task-maker-exec/src/scheduler.rs @@ -555,10 +555,7 @@ impl Scheduler { /// This will also send the file to the client, if needed. fn file_failed(&mut self, client_uuid: ClientUuid, file: FileUuid) -> Result<(), Error> { self.send_file(client_uuid, file, false).with_context(|| { - format!( - "Failed sending failed file {} to client {}", - file, client_uuid - ) + format!("Failed sending failed file {file} to client {client_uuid}") })?; let client = if let Some(client) = self.clients.get_mut(&client_uuid) { client @@ -604,10 +601,7 @@ impl Scheduler { /// This will also send the file to the client, if needed. fn file_success(&mut self, client_uuid: ClientUuid, file: FileUuid) -> Result<(), Error> { self.send_file(client_uuid, file, true).with_context(|| { - format!( - "Failed sending succeeded file {} to client {}", - file, client_uuid - ) + format!("Failed sending succeeded file {file} to client {client_uuid}") })?; let client = if let Some(client) = self.clients.get_mut(&client_uuid) { client @@ -839,7 +833,7 @@ impl Scheduler { let handle = client .file_handles .get(&file) - .unwrap_or_else(|| panic!("Unknown file key of {}", file)) + .unwrap_or_else(|| panic!("Unknown file key of {file}")) .key() .clone(); dep_keys.insert(file, handle); diff --git a/task-maker-exec/src/worker.rs b/task-maker-exec/src/worker.rs index 026bea6d7..b29f3d901 100644 --- a/task-maker-exec/src/worker.rs +++ b/task-maker-exec/src/worker.rs @@ -228,7 +228,7 @@ impl Worker { let handle = self .file_store .store(&key, reader) - .with_context(|| format!("Failed to store server-provided file {}", key))?; + .with_context(|| format!("Failed to store server-provided file {key}"))?; let should_start = { let mut job = self.current_job.lock().unwrap(); let uuids = job @@ -359,7 +359,7 @@ fn execute_job( let sender = sender.clone(); let description = job.group.description.clone(); let join_handle = std::thread::Builder::new() - .name(format!("Sandbox group manager for {}", description)) + .name(format!("Sandbox group manager for {description}")) .spawn(move || { sandbox_group_manager( current_job, @@ -370,7 +370,7 @@ fn execute_job( runner, fifo_dir, ) - .with_context(|| format!("Sandbox group for {} failed", description)) + .with_context(|| format!("Sandbox group for {description} failed")) // FIXME: find a better way to propagate the error to the server .unwrap(); })?; @@ -541,7 +541,7 @@ fn spawn_sandbox( group_sender: Sender<(usize, SandboxResult)>, ) -> Result>, Error> { Ok(thread::Builder::new() - .name(format!("Sandbox of {}", description)) + .name(format!("Sandbox of {description}")) .spawn(move || { let res = match sandbox.run(runner.as_ref()) { Ok(res) => res, @@ -572,14 +572,12 @@ fn compute_execution_result( let stderr = capture_stream(&sandbox.stderr_path(), execution.capture_stderr); let status = match (&stdout, &stderr) { (Ok(_), Ok(_)) => execution.status(exit_status, signal, &resources), - (Err(err), _) => ExecutionStatus::internal_error(format!( - "Failed to read stdout file: {:?}", - err - )), - (_, Err(err)) => ExecutionStatus::internal_error(format!( - "Failed to read stderr file: {:?}", - err - )), + (Err(err), _) => { + ExecutionStatus::internal_error(format!("Failed to read stdout file: {err:?}")) + } + (_, Err(err)) => { + ExecutionStatus::internal_error(format!("Failed to read stderr file: {err:?}")) + } }; ExecutionResult { status, diff --git a/task-maker-format/src/detect_format.rs b/task-maker-format/src/detect_format.rs index 1562be8c9..44179a73e 100644 --- a/task-maker-format/src/detect_format.rs +++ b/task-maker-format/src/detect_format.rs @@ -57,7 +57,7 @@ pub fn find_task( path.display() ); error.chain().for_each(|cause| { - let _ = write!(message, " Caused by:\n {}\n", cause); + let _ = write!(message, " Caused by:\n {cause}\n"); }); } diff --git a/task-maker-format/src/ioi/curses_ui.rs b/task-maker-format/src/ioi/curses_ui.rs index 6f8c60986..3a861b162 100644 --- a/task-maker-format/src/ioi/curses_ui.rs +++ b/task-maker-format/src/ioi/curses_ui.rs @@ -150,14 +150,14 @@ fn draw_booklets(frame: &mut Frame, rect: Rect, state: &UIState, loading: char) .flat_map(|name| { let booklet = &state.booklets[name]; let mut text: Vec = vec![vec![ - Span::raw(format!("{:<20} ", name)), + Span::raw(format!("{name:<20} ")), ui_execution_status_text(&booklet.status, loading), ] .into()]; for name in booklet.dependencies.keys().sorted() { let mut line = Vec::new(); let dep = &booklet.dependencies[name]; - line.push(Span::raw(format!(" {:<18} ", name))); + line.push(Span::raw(format!(" {name:<18} "))); line.push(Span::raw("[")); for step in dep { line.push(ui_execution_status_text(&step.status, loading)); @@ -175,7 +175,7 @@ fn draw_booklets(frame: &mut Frame, rect: Rect, state: &UIState, loading: char) fn ui_execution_status_text(status: &UIExecutionStatus, loading: char) -> Span { match status { UIExecutionStatus::Pending => Span::raw("."), - UIExecutionStatus::Started { .. } => Span::raw(format!("{}", loading)), + UIExecutionStatus::Started { .. } => Span::raw(format!("{loading}")), UIExecutionStatus::Skipped => Span::raw("S"), UIExecutionStatus::Done { result } => match &result.status { ExecutionStatus::Success => Span::styled("S", *GREEN), @@ -212,11 +212,11 @@ fn draw_generations(frame: &mut Frame, rect: Rect, state: &UIState, loading: cha fn generation_status_text(status: &TestcaseGenerationStatus, loading: char) -> Span { match status { TestcaseGenerationStatus::Pending => Span::raw("."), - TestcaseGenerationStatus::Generating => Span::raw(format!("{}", loading)), + TestcaseGenerationStatus::Generating => Span::raw(format!("{loading}")), TestcaseGenerationStatus::Generated => Span::styled("G", *GREEN), - TestcaseGenerationStatus::Validating => Span::raw(format!("{}", loading)), + TestcaseGenerationStatus::Validating => Span::raw(format!("{loading}")), TestcaseGenerationStatus::Validated => Span::styled("V", *GREEN), - TestcaseGenerationStatus::Solving => Span::raw(format!("{}", loading)), + TestcaseGenerationStatus::Solving => Span::raw(format!("{loading}")), TestcaseGenerationStatus::Solved => Span::styled("S", *GREEN), TestcaseGenerationStatus::Failed => Span::styled("F", *RED), TestcaseGenerationStatus::Skipped => Span::styled("s", *YELLOW), @@ -269,9 +269,9 @@ fn evaluation_score<'a>(state: &'a UIState, solution: &Path, loading: char) -> S }; if let Some(score) = sol_state.score { match ScoreStatus::from_score(score, state.max_score) { - ScoreStatus::WrongAnswer => Span::styled(format!(" {:>3.0} ", score), *RED), - ScoreStatus::Accepted => Span::styled(format!(" {:>3.0} ", score), *GREEN), - ScoreStatus::PartialScore => Span::styled(format!(" {:>3.0} ", score), *YELLOW), + ScoreStatus::WrongAnswer => Span::styled(format!(" {score:>3.0} "), *RED), + ScoreStatus::Accepted => Span::styled(format!(" {score:>3.0} "), *GREEN), + ScoreStatus::PartialScore => Span::styled(format!(" {score:>3.0} "), *YELLOW), } } else { let has_skipped = sol_state @@ -281,7 +281,7 @@ fn evaluation_score<'a>(state: &'a UIState, solution: &Path, loading: char) -> S if has_skipped { Span::raw(" X ") } else { - Span::raw(format!(" {} ", loading)) + Span::raw(format!(" {loading} ")) } } } @@ -350,9 +350,9 @@ fn testcase_evaluation_status_text<'a>( }; match &testcase.status { TestcaseEvaluationStatus::Pending => Span::raw("."), - TestcaseEvaluationStatus::Solving => Span::raw(format!("{}", loading)), + TestcaseEvaluationStatus::Solving => Span::raw(format!("{loading}")), TestcaseEvaluationStatus::Solved => Span::raw("s"), - TestcaseEvaluationStatus::Checking => Span::raw(format!("{}", loading)), + TestcaseEvaluationStatus::Checking => Span::raw(format!("{loading}")), TestcaseEvaluationStatus::Accepted(_) => Span::styled("A", close_color.unwrap_or(*GREEN)), TestcaseEvaluationStatus::WrongAnswer(_) => Span::styled("W", *RED), TestcaseEvaluationStatus::Partial(_) => Span::styled("P", *YELLOW), diff --git a/task-maker-format/src/ioi/dag/checker.rs b/task-maker-format/src/ioi/dag/checker.rs index 92435fc16..e028b8eaa 100644 --- a/task-maker-format/src/ioi/dag/checker.rs +++ b/task-maker-format/src/ioi/dag/checker.rs @@ -106,8 +106,7 @@ impl Checker { if !res.status.is_success() { let message = if let Some(testcase_id) = testcase_id { format!( - "Checker failed while computing a score for testcase {}", - testcase_id + "Checker failed while computing a score for testcase {testcase_id}" ) } else { "Checker failed while computing a score for a testcase".into() @@ -125,15 +124,14 @@ impl Checker { Err(e) => { let message = if let Some(testcase_id) = testcase_id { format!( - "Checker returned an invalid score ({:?}) for testcase {}", - score, testcase_id + "Checker returned an invalid score ({score:?}) for testcase {testcase_id}" ) } else { - format!("Checker returned an invalid score ({:?})", score) + format!("Checker returned an invalid score ({score:?})") }; let diagnostic = Diagnostic::error(message) .with_note(description) - .with_help(format!("The parse error is: {:?}", e)) + .with_help(format!("The parse error is: {e:?}")) .with_help_attachment(stdout); sender.add_diagnostic(diagnostic)?; return Ok(()); diff --git a/task-maker-format/src/ioi/dag/input_generator.rs b/task-maker-format/src/ioi/dag/input_generator.rs index 8f80fdcb8..7c754d291 100644 --- a/task-maker-format/src/ioi/dag/input_generator.rs +++ b/task-maker-format/src/ioi/dag/input_generator.rs @@ -40,8 +40,7 @@ impl InputGenerator { bail!("COPY from not existing file: {:?}", path); } let file = File::new(format!( - "Static input file of testcase {}, subtask {} from {:?}", - subtask_id, testcase_id, path + "Static input file of testcase {subtask_id}, subtask {testcase_id} from {path:?}" )); let uuid = file.uuid; eval.dag.provide_file(file, path).with_context(|| { @@ -92,10 +91,7 @@ impl InputGenerator { let (input, gen) = self.generate( eval, task_path, - format!( - "Generation of input file of testcase {}, subtask {}", - testcase_id, subtask_id - ), + format!("Generation of input file of testcase {testcase_id}, subtask {subtask_id}"), subtask_id, testcase_id, )?; @@ -103,7 +99,7 @@ impl InputGenerator { input, eval.task_root .join("input") - .join(format!("input{}.txt", testcase_id)), + .join(format!("input{testcase_id}.txt")), false, ); // If there is an execution, bind its callbacks and store the input file. @@ -119,8 +115,8 @@ impl InputGenerator { eval.dag.on_execution_done(&gen.uuid, move |result| { if !result.status.is_success() { let mut diagnostic = - Diagnostic::error(format!("Failed to generate input {}", testcase_id)) - .with_note(format!("Generator arguments are: {}", args)); + Diagnostic::error(format!("Failed to generate input {testcase_id}")) + .with_note(format!("Generator arguments are: {args}")); if let Some(stderr) = result.stderr { diagnostic = diagnostic.with_help_attachment(stderr); } diff --git a/task-maker-format/src/ioi/dag/input_validator.rs b/task-maker-format/src/ioi/dag/input_validator.rs index 760be3106..4ba63b30b 100644 --- a/task-maker-format/src/ioi/dag/input_validator.rs +++ b/task-maker-format/src/ioi/dag/input_validator.rs @@ -94,10 +94,7 @@ impl InputValidator { let (handle, val) = self.validate( eval, task_path, - format!( - "Validation of input file of testcase {}, subtask {}", - testcase_id, subtask_id - ), + format!("Validation of input file of testcase {testcase_id}, subtask {subtask_id}"), subtask_id, subtask_name, testcase_id, @@ -114,8 +111,7 @@ impl InputValidator { eval.dag.on_execution_done(&val.uuid, move |result| { if !result.status.is_success() { let mut diagnostic = Diagnostic::error(format!( - "Failed to validate input {} for subtask {}", - testcase_id, subtask_id + "Failed to validate input {testcase_id} for subtask {subtask_id}" )); if let Some(stderr) = result.stderr { diagnostic = diagnostic.with_help_attachment(stderr); diff --git a/task-maker-format/src/ioi/dag/output_generator.rs b/task-maker-format/src/ioi/dag/output_generator.rs index 7dda1e6b7..958061df3 100644 --- a/task-maker-format/src/ioi/dag/output_generator.rs +++ b/task-maker-format/src/ioi/dag/output_generator.rs @@ -52,8 +52,7 @@ impl OutputGenerator { bail!("Static output file not found: {:?}", path); } let file = File::new(format!( - "Static output file of testcase {}, subtask {} from {:?}", - subtask_id, testcase_id, path + "Static output file of testcase {subtask_id}, subtask {testcase_id} from {path:?}" )); let uuid = file.uuid; eval.dag.provide_file(file, path).with_context(|| { @@ -90,10 +89,7 @@ impl OutputGenerator { let (output, sol) = self.generate( task, eval, - format!( - "Generation of output file of testcase {}, subtask {}", - testcase_id, subtask_id - ), + format!("Generation of output file of testcase {testcase_id}, subtask {subtask_id}"), subtask_id, testcase_id, input, @@ -110,7 +106,7 @@ impl OutputGenerator { eval.dag.on_execution_done(&sol.uuid, move |result| { if !result.status.is_success() { let mut diagnostic = - Diagnostic::error(format!("Failed to generate output {}", testcase_id)); + Diagnostic::error(format!("Failed to generate output {testcase_id}")); if let Some(stderr) = result.stderr { diagnostic = diagnostic.with_help_attachment(stderr); } @@ -125,7 +121,7 @@ impl OutputGenerator { output, task.path .join("output") - .join(format!("output{}.txt", testcase_id)), + .join(format!("output{testcase_id}.txt")), false, ); } diff --git a/task-maker-format/src/ioi/dag/task_type/communication.rs b/task-maker-format/src/ioi/dag/task_type/communication.rs index 749962c14..500af61ff 100644 --- a/task-maker-format/src/ioi/dag/task_type/communication.rs +++ b/task-maker-format/src/ioi/dag/task_type/communication.rs @@ -332,10 +332,7 @@ impl ScoreSender { data.sender.clone(), ) .with_context(|| { - format!( - "Failed to store testcase score (score: {}, message: {})", - score, message - ) + format!("Failed to store testcase score (score: {score}, message: {message})") })?; } Ok(()) diff --git a/task-maker-format/src/ioi/finish_ui.rs b/task-maker-format/src/ioi/finish_ui.rs index a1d252370..e8efbf793 100644 --- a/task-maker-format/src/ioi/finish_ui.rs +++ b/task-maker-format/src/ioi/finish_ui.rs @@ -76,7 +76,7 @@ impl FinishUI { state .task .time_limit - .map(|t| format!("{}s", t)) + .map(|t| format!("{t}s")) .unwrap_or_else(|| "unlimited".to_string()) ); cwrite!(self, BOLD, "Memory limit: "); @@ -85,7 +85,7 @@ impl FinishUI { state .task .memory_limit - .map(|t| format!("{}MiB", t)) + .map(|t| format!("{t}MiB")) .unwrap_or_else(|| "unlimited".to_string()) ); } @@ -100,7 +100,7 @@ impl FinishUI { println!(); for name in booklet.dependencies.keys().sorted() { let dep = &booklet.dependencies[name]; - print!(" {:<18} ", name); + print!(" {name:<18} "); let mut first = true; for step in dep.iter() { if first { @@ -121,11 +121,11 @@ impl FinishUI { for (st_num, subtask) in state.generations.iter().sorted_by_key(|(n, _)| *n) { cwrite!(self, BOLD, "Subtask {}", st_num); if let Some(name) = &state.task.subtasks[st_num].name { - print!(" [{}]", name); + print!(" [{name}]"); } println!(": {} points", state.task.subtasks[st_num].max_score); for (tc_num, testcase) in subtask.testcases.iter().sorted_by_key(|(n, _)| *n) { - print!("#{:<3} ", tc_num); + print!("#{tc_num:<3} "); let mut first = true; let mut gen_failed = false; @@ -229,7 +229,7 @@ impl FinishUI { for (st_num, subtask) in eval.subtasks.iter().sorted_by_key(|(n, _)| *n) { cwrite!(self, BOLD, "Subtask #{}", st_num); if let Some(name) = &state.task.subtasks[st_num].name { - print!(" [{}]", name); + print!(" [{name}]"); } print!(": "); let max_score = state.task.subtasks[st_num].max_score; @@ -254,7 +254,7 @@ impl FinishUI { max_memory: u64, state: &UIState, ) { - print!("{:3}) ", tc_num); + print!("{tc_num:3}) "); let score_precision = Self::score_precision(&state.task); if let Some(score) = testcase.score { if abs_diff_eq!(score, 1.0) { @@ -305,9 +305,9 @@ impl FinishUI { } for result in testcase.results.iter().flatten() { match &result.status { - ExecutionStatus::ReturnCode(code) => print!(": Exited with {}", code), - ExecutionStatus::Signal(sig, name) => print!(": Signal {} ({})", sig, name), - ExecutionStatus::InternalError(err) => print!(": Internal error: {}", err), + ExecutionStatus::ReturnCode(code) => print!(": Exited with {code}"), + ExecutionStatus::Signal(sig, name) => print!(": Signal {sig} ({name})"), + ExecutionStatus::InternalError(err) => print!(": Internal error: {err}"), _ => {} } } @@ -318,7 +318,7 @@ impl FinishUI { print!(" (from cache)"); } if FinishUI::is_ansi() { - self.print_right(format!("[{}]", name)); + self.print_right(format!("[{name}]")); } println!(); } @@ -363,12 +363,7 @@ impl FinishUI { width = max_len ); if let Some(score) = eval.score { - print!( - "{:>width$.prec$} | ", - score, - width = column_width, - prec = score_precision - ); + print!("{score:>column_width$.score_precision$} | "); } else if score_precision == 0 { print!("{:>width$} | ", "X", width = column_width); } else { @@ -452,7 +447,7 @@ impl FinishUI { prec = task.score_precision ); } else if task.score_precision == 0 { - print!("X / {:.0}", max_score,); + print!("X / {max_score:.0}",); } else { print!( "X.{:X) -> std::fmt::Result { match self { - ConstraintOperand::Constant(k) => write!(f, "{}", k), - ConstraintOperand::Variable(v) => write!(f, "${}", v), + ConstraintOperand::Constant(k) => write!(f, "{k}"), + ConstraintOperand::Variable(v) => write!(f, "${v}"), } } } @@ -773,9 +770,9 @@ impl Debug for Constraint { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { let mut constraint = self.operands[0].to_string(); for (op, var) in self.operators.iter().zip(self.operands[1..].iter()) { - let _ = write!(constraint, " {} {}", op, var); + let _ = write!(constraint, " {op} {var}"); } - write!(f, "{}", constraint) + write!(f, "{constraint}") } } @@ -807,7 +804,7 @@ mod tests { if !error.contains(message) { AssertionFailure::from_spec(self) .with_actual(error) - .with_expected(format!("error containing <\"{}\">", message)) + .with_expected(format!("error containing <\"{message}\">")) .fail(); } } @@ -1228,7 +1225,7 @@ mod tests { assert_eq!(subtask.name, None); assert_abs_diff_eq!(subtask.max_score, 42.0); } else { - panic!("Expecting a subtask, got: {:?}", subtask); + panic!("Expecting a subtask, got: {subtask:?}"); } } @@ -1243,7 +1240,7 @@ mod tests { assert_eq!(subtask.name, Some("the-name".into())); assert_abs_diff_eq!(subtask.max_score, 42.0); } else { - panic!("Expecting a subtask, got: {:?}", subtask); + panic!("Expecting a subtask, got: {subtask:?}"); } } @@ -1260,7 +1257,7 @@ mod tests { assert_eq!(subtask.name, Some("thename".into())); assert_abs_diff_eq!(subtask.max_score, 42.42); } else { - panic!("Expecting a subtask, got: {:?}", subtask); + panic!("Expecting a subtask, got: {subtask:?}"); } } @@ -1277,7 +1274,7 @@ mod tests { assert_eq!(subtask.name, Some("the-name".into())); assert_abs_diff_eq!(subtask.max_score, 42.42); } else { - panic!("Expecting a subtask, got: {:?}", subtask); + panic!("Expecting a subtask, got: {subtask:?}"); } } @@ -1295,7 +1292,7 @@ mod tests { assert_eq!(gen.result.len(), 2); let subtask = &gen.result[0]; let TaskInputEntry::Subtask(subtask) = subtask else { - panic!("Expecting a subtask, got: {:?}", subtask); + panic!("Expecting a subtask, got: {subtask:?}"); }; assert_eq!(subtask.id, 0); if let InputValidator::Custom(_, args) = &subtask.input_validator { @@ -1321,7 +1318,7 @@ mod tests { assert_eq!(gen.result.len(), 2); let subtask = &gen.result[0]; let TaskInputEntry::Subtask(subtask) = subtask else { - panic!("Expecting a subtask, got: {:?}", subtask); + panic!("Expecting a subtask, got: {subtask:?}"); }; assert_eq!(subtask.id, 0); if let InputValidator::Custom(source, args) = &subtask.input_validator { @@ -1359,7 +1356,7 @@ mod tests { ); } } else { - panic!("Expecting a testcase, got: {:?}", testcase); + panic!("Expecting a testcase, got: {testcase:?}"); } } @@ -1402,7 +1399,7 @@ mod tests { ); } } else { - panic!("Expecting a testcase, got: {:?}", testcase); + panic!("Expecting a testcase, got: {testcase:?}"); } } @@ -1427,7 +1424,7 @@ mod tests { ); } } else { - panic!("Expecting a testcase, got: {:?}", testcase); + panic!("Expecting a testcase, got: {testcase:?}"); } } @@ -1481,7 +1478,7 @@ mod tests { ); } } else { - panic!("Expecting a testcase, got: {:?}", testcase); + panic!("Expecting a testcase, got: {testcase:?}"); } } @@ -1508,7 +1505,7 @@ mod tests { ); } } else { - panic!("Expecting a testcase, got: {:?}", testcase); + panic!("Expecting a testcase, got: {testcase:?}"); } } @@ -1535,7 +1532,7 @@ mod tests { ); } } else { - panic!("Expecting a testcase, got: {:?}", testcase); + panic!("Expecting a testcase, got: {testcase:?}"); } } @@ -1561,7 +1558,7 @@ mod tests { ); } } else { - panic!("Expecting a testcase, got: {:?}", testcase); + panic!("Expecting a testcase, got: {testcase:?}"); } } diff --git a/task-maker-format/src/ioi/format/italian_yaml/gen_gen.rs b/task-maker-format/src/ioi/format/italian_yaml/gen_gen.rs index 278bd1b8b..80ac3b4cb 100644 --- a/task-maker-format/src/ioi/format/italian_yaml/gen_gen.rs +++ b/task-maker-format/src/ioi/format/italian_yaml/gen_gen.rs @@ -129,7 +129,7 @@ where } subtask.name = Some( cleanup_subtask_name(name) - .with_context(|| format!("Invalid subtask name: {}", name))?, + .with_context(|| format!("Invalid subtask name: {name}"))?, ); let old_id = st_name_to_id.insert(subtask.name.clone().unwrap(), subtask.id); @@ -290,7 +290,7 @@ mod tests { InputGenerator::StaticFile(_) => panic!("Invalid generator"), } } else { - panic!("Wrong entries returned: {:?}", entries); + panic!("Wrong entries returned: {entries:?}"); } } @@ -306,7 +306,7 @@ mod tests { InputGenerator::StaticFile(_) => panic!("Invalid generator"), } } else { - panic!("Wrong entries returned: {:?}", entries); + panic!("Wrong entries returned: {entries:?}"); } } @@ -323,7 +323,7 @@ mod tests { InputGenerator::StaticFile(_) => panic!("Invalid generator"), } } else { - panic!("Wrong entries returned: {:?}", entries); + panic!("Wrong entries returned: {entries:?}"); } } @@ -339,7 +339,7 @@ mod tests { InputGenerator::StaticFile(_) => panic!("Invalid generator"), } } else { - panic!("Wrong entries returned: {:?}", entries); + panic!("Wrong entries returned: {entries:?}"); } } @@ -355,7 +355,7 @@ mod tests { InputGenerator::StaticFile(_) => panic!("Invalid generator"), } } else { - panic!("Wrong entries returned: {:?}", entries); + panic!("Wrong entries returned: {entries:?}"); } } @@ -376,7 +376,7 @@ mod tests { InputGenerator::StaticFile(_) => panic!("Invalid generator"), } } else { - panic!("Wrong entries returned: {:?}", entries); + panic!("Wrong entries returned: {entries:?}"); } } @@ -397,7 +397,7 @@ mod tests { InputGenerator::StaticFile(_) => panic!("Invalid generator"), } } else { - panic!("Wrong entries returned: {:?}", entries); + panic!("Wrong entries returned: {entries:?}"); } } @@ -421,7 +421,7 @@ mod tests { InputGenerator::StaticFile(_) => panic!("Invalid generator"), } } else { - panic!("Wrong entries returned: {:?}", entries); + panic!("Wrong entries returned: {entries:?}"); } } @@ -453,7 +453,7 @@ mod tests { InputGenerator::StaticFile(_) => panic!("Invalid generator"), } } else { - panic!("Wrong entries returned: {:?}", entries); + panic!("Wrong entries returned: {entries:?}"); } } @@ -471,7 +471,7 @@ mod tests { assert_eq!(subtask2.max_score as u32, 321); assert_eq!(subtask2.name.as_deref(), Some("wow")); } else { - panic!("Wrong entries returned: {:?}", entries); + panic!("Wrong entries returned: {entries:?}"); } } @@ -490,7 +490,7 @@ mod tests { assert_eq!(subtask2.max_score as u32, 321); assert_eq!(subtask2.name.as_deref(), Some("wow")); } else { - panic!("Wrong entries returned: {:?}", entries); + panic!("Wrong entries returned: {entries:?}"); } } @@ -511,7 +511,7 @@ mod tests { InputGenerator::StaticFile(_) => panic!("Invalid generator"), } } else { - panic!("Wrong entries returned: {:?}", entries); + panic!("Wrong entries returned: {entries:?}"); } } @@ -527,7 +527,7 @@ mod tests { InputGenerator::StaticFile(_) => panic!("Invalid generator"), } } else { - panic!("Wrong entries returned: {:?}", entries); + panic!("Wrong entries returned: {entries:?}"); } } diff --git a/task-maker-format/src/ioi/format/italian_yaml/mod.rs b/task-maker-format/src/ioi/format/italian_yaml/mod.rs index 95b565b9a..ee6d81cab 100644 --- a/task-maker-format/src/ioi/format/italian_yaml/mod.rs +++ b/task-maker-format/src/ioi/format/italian_yaml/mod.rs @@ -660,7 +660,7 @@ pub fn parse_task>( })?; let mut buf_file = BufWriter::new(file); writeln!(buf_file, "# Generated by task-maker. Do not edit!")?; - writeln!(buf_file, "# {}", TM_ALLOW_DELETE_COOKIE)?; + writeln!(buf_file, "# {TM_ALLOW_DELETE_COOKIE}")?; writeln!(buf_file, "# Removing or changing the line above will prevent task-maker from touching this file again.")?; serde_yaml::to_writer(buf_file, &yaml).context("Failed to serialize task.yaml")?; } @@ -793,7 +793,7 @@ fn detect_output_generator( if let Some(solution) = official_solution.as_ref() { OutputGenerator::Custom(solution.clone(), vec![]) } else { - OutputGenerator::StaticFile(output_directory.join(format!("output{}.txt", tc))) + OutputGenerator::StaticFile(output_directory.join(format!("output{tc}.txt"))) } }) } diff --git a/task-maker-format/src/ioi/format/italian_yaml/static_inputs.rs b/task-maker-format/src/ioi/format/italian_yaml/static_inputs.rs index 6826182f3..6790e3208 100644 --- a/task-maker-format/src/ioi/format/italian_yaml/static_inputs.rs +++ b/task-maker-format/src/ioi/format/italian_yaml/static_inputs.rs @@ -45,7 +45,7 @@ where })); } let id = self.index - 1; // offset caused by the first iteration - let path = self.path.join(format!("input{}.txt", id)); + let path = self.path.join(format!("input{id}.txt")); if path.exists() { self.index += 1; Some(TaskInputEntry::Testcase(TestcaseInfo::new( @@ -106,11 +106,7 @@ mod tests { let dir = TempDir::new().unwrap(); fs::create_dir(dir.path().join("input")).unwrap(); for tc in iter.into_iter() { - fs::write( - dir.path().join("input").join(format!("input{}.txt", tc)), - "", - ) - .unwrap(); + fs::write(dir.path().join("input").join(format!("input{tc}.txt")), "").unwrap(); } dir } @@ -144,7 +140,7 @@ mod tests { InputGenerator::Custom(_, _) => panic!("Invalid generator"), } } else { - panic!("Wrong entries returned: {:?}", entries); + panic!("Wrong entries returned: {entries:?}"); } } @@ -157,7 +153,7 @@ mod tests { assert_eq!(subtask.id, 0); assert_eq!(subtask.max_score as u32, 100); } else { - panic!("Wrong entries returned: {:?}", entries); + panic!("Wrong entries returned: {entries:?}"); } } } diff --git a/task-maker-format/src/ioi/sanity_checks/att.rs b/task-maker-format/src/ioi/sanity_checks/att.rs index 6e99aff39..c0287f8ff 100644 --- a/task-maker-format/src/ioi/sanity_checks/att.rs +++ b/task-maker-format/src/ioi/sanity_checks/att.rs @@ -66,7 +66,7 @@ impl SanityCheck for AttTemplates { if !template.exists() { let grader_name = task.path_of(grader); eval.add_diagnostic( - Diagnostic::warning(format!("Missing template at {}", att_name)) + Diagnostic::warning(format!("Missing template at {att_name}")) .with_note(format!("Because of {}", grader_name.display())), )?; } @@ -158,7 +158,7 @@ impl SanityCheck for AttSampleFiles { .join(", "); eval.add_diagnostic( Diagnostic::error("Missing samples in att/") - .with_note(format!("Samples in the task, but not in att/: {}", paths)), + .with_note(format!("Samples in the task, but not in att/: {paths}")), )?; } if !missing_in_task.is_empty() { @@ -168,7 +168,7 @@ impl SanityCheck for AttSampleFiles { .join(", "); eval.add_diagnostic( Diagnostic::error("Missing samples in the task") - .with_note(format!("Samples in att/, but not in the task: {}", paths)), + .with_note(format!("Samples in att/, but not in the task: {paths}")), )?; } } @@ -361,8 +361,8 @@ fn get_sample_files( .map(|p| task.path_of(p).to_string_lossy()) .join(", "); eval.add_diagnostic( - Diagnostic::error(format!("Sample input {} is present more than once", num)) - .with_note(format!("Found at: {}", paths)), + Diagnostic::error(format!("Sample input {num} is present more than once")) + .with_note(format!("Found at: {paths}")), )?; } let mut outputs: HashMap<_, Vec<_>> = HashMap::new(); @@ -380,8 +380,8 @@ fn get_sample_files( .map(|p| task.path_of(p).to_string_lossy()) .join(", "); eval.add_diagnostic( - Diagnostic::error(format!("Sample output {} is present more than once", num)) - .with_note(format!("Found at: {}", paths)), + Diagnostic::error(format!("Sample output {num} is present more than once")) + .with_note(format!("Found at: {paths}")), )?; } let mut samples = Vec::new(); @@ -554,7 +554,7 @@ impl SanityCheck for AttTemplatesShouldCompile { .file_name() .ok_or_else(|| anyhow!("Grader has no file name"))? .to_string_lossy(); - let att_grader_name = format!("att/{}", grader_name); + let att_grader_name = format!("att/{grader_name}"); let att_grader = task.path.join(&att_grader_name); // Only run the check if the grader is not a symlink, as otherwise we are already @@ -567,10 +567,7 @@ impl SanityCheck for AttTemplatesShouldCompile { let source_file = SourceFile::new( template, &task.path, - format!( - "Template {} compiled with attached grader {}", - att_name, att_grader_name - ), + format!("Template {att_name} compiled with attached grader {att_grader_name}"), Some(Arc::new(grader_map)), None::, ); diff --git a/task-maker-format/src/ioi/sanity_checks/checker.rs b/task-maker-format/src/ioi/sanity_checks/checker.rs index f516aee1c..ba84478a0 100644 --- a/task-maker-format/src/ioi/sanity_checks/checker.rs +++ b/task-maker-format/src/ioi/sanity_checks/checker.rs @@ -56,8 +56,7 @@ impl SanityCheck for FuzzCheckerWithJunkOutput { for (description, content) in &*JUNK_OUTPUTS { let test_output = File::new(format!( - "Junk input for fuzzing checker with '{}'", - description + "Junk input for fuzzing checker with '{description}'" )); let test_output_uuid = test_output.uuid; eval.dag.provide_content(test_output, content.to_vec()); @@ -83,8 +82,7 @@ impl SanityCheck for FuzzCheckerWithJunkOutput { move |score, outcome| { if score != 0.0 { sender.add_diagnostic(Diagnostic::error(format!( - "Junk file '{}' scored {} (with message '{}')", - description, score, outcome + "Junk file '{description}' scored {score} (with message '{outcome}')" )))?; } Ok(()) @@ -92,8 +90,7 @@ impl SanityCheck for FuzzCheckerWithJunkOutput { ) .with_context(|| { format!( - "Failed to build DAG for fuzzing the checker with '{}'", - description + "Failed to build DAG for fuzzing the checker with '{description}'" ) })?; diff --git a/task-maker-format/src/ioi/sanity_checks/io.rs b/task-maker-format/src/ioi/sanity_checks/io.rs index dbfa863c5..8c9c452f7 100644 --- a/task-maker-format/src/ioi/sanity_checks/io.rs +++ b/task-maker-format/src/ioi/sanity_checks/io.rs @@ -104,7 +104,7 @@ impl SanityCheck for IOEndWithNewLine { CheckEndWithNewLine::bind( eval, input_file, - format!("input/input{}.txt", testcase_id), + format!("input/input{testcase_id}.txt"), self.inputs.clone(), ); } @@ -112,7 +112,7 @@ impl SanityCheck for IOEndWithNewLine { CheckEndWithNewLine::bind( eval, output_file, - format!("output/output{}.txt", testcase_id), + format!("output/output{testcase_id}.txt"), self.outputs.clone(), ); } diff --git a/task-maker-format/src/ioi/sanity_checks/statement.rs b/task-maker-format/src/ioi/sanity_checks/statement.rs index 92057899c..cfae8ba7a 100644 --- a/task-maker-format/src/ioi/sanity_checks/statement.rs +++ b/task-maker-format/src/ioi/sanity_checks/statement.rs @@ -254,8 +254,7 @@ impl SanityCheck for StatementCompiledOrGit { task.path_of(target).display() )) .with_help(format!( - "Maybe it should be a symlink to one of the compiled PDF ({})", - booklet_dest_list + "Maybe it should be a symlink to one of the compiled PDF ({booklet_dest_list})" )), )?; diff --git a/task-maker-format/src/ioi/sanity_checks/subtasks.rs b/task-maker-format/src/ioi/sanity_checks/subtasks.rs index c9a709722..b52b7a0d9 100644 --- a/task-maker-format/src/ioi/sanity_checks/subtasks.rs +++ b/task-maker-format/src/ioi/sanity_checks/subtasks.rs @@ -97,7 +97,7 @@ impl SanityCheck for InvalidSubtaskName { check.subtask_name_pattern, solution.source_file.relative_path().display() )) - .with_note(format!("The valid names are: {}", subtask_names)), + .with_note(format!("The valid names are: {subtask_names}")), )?; } } @@ -216,7 +216,7 @@ impl SanityCheck for AllOutputsEqual { let name = subtask .name .as_ref() - .map(|name| format!(" ({})", name)) + .map(|name| format!(" ({name})")) .unwrap_or_default(); let message = format!("All outputs for subtask {id}{name} are identical"); diff --git a/task-maker-format/src/ioi/sanity_checks/task.rs b/task-maker-format/src/ioi/sanity_checks/task.rs index e9b1d7e44..621c758c2 100644 --- a/task-maker-format/src/ioi/sanity_checks/task.rs +++ b/task-maker-format/src/ioi/sanity_checks/task.rs @@ -34,8 +34,7 @@ impl SanityCheck for TaskMaxScore { let task_score: f64 = task.subtasks.values().map(|st| st.max_score).sum(); if approx::abs_diff_ne!(task_score, DEFAULT_TASK_MAX_SCORE) { eval.add_diagnostic(Diagnostic::error(format!( - "The score of the task is {} (not {})", - task_score, DEFAULT_TASK_MAX_SCORE + "The score of the task is {task_score} (not {DEFAULT_TASK_MAX_SCORE})" )))?; } Ok(()) diff --git a/task-maker-format/src/ioi/statement/asy.rs b/task-maker-format/src/ioi/statement/asy.rs index 27036142f..3876c9dc1 100644 --- a/task-maker-format/src/ioi/statement/asy.rs +++ b/task-maker-format/src/ioi/statement/asy.rs @@ -30,10 +30,10 @@ impl AsyFile { .ok_or_else(|| anyhow!("Invalid path of asy file: {:?}", source_path))? .to_string_lossy() .to_string(); - let source_file = File::new(format!("Source of {}", name)); + let source_file = File::new(format!("Source of {name}")); let mut comp = Execution::new( - format!("Compilation of {}", name), + format!("Compilation of {name}"), ExecutionCommand::system("asy"), ); comp.args(vec![ @@ -88,8 +88,8 @@ impl AsyFile { let compiled = comp.output("tm-compilation.pdf"); if eval.dag.data.config.copy_logs { let log_dir = eval.task_root.join("bin/logs/asy"); - let stderr_dest = log_dir.join(format!("{}.stderr.log", name)); - let stdout_dest = log_dir.join(format!("{}.stdout.log", name)); + let stderr_dest = log_dir.join(format!("{name}.stderr.log")); + let stdout_dest = log_dir.join(format!("{name}.stdout.log")); eval.dag .write_file_to_allow_fail(comp.stderr(), stderr_dest, false); eval.dag @@ -102,7 +102,7 @@ impl AsyFile { let name = name.clone(); move |result| { if !result.status.is_success() { - let mut diagnostic = Diagnostic::error(format!("Failed to compile {}", name)); + let mut diagnostic = Diagnostic::error(format!("Failed to compile {name}")); if result.status.is_internal_error() { diagnostic = diagnostic.with_help("Is 'asymptote' installed?"); } @@ -117,7 +117,7 @@ impl AsyFile { eval.dag.add_execution(comp); let mut crop = Execution::new( - format!("Crop of {}", name), + format!("Crop of {name}"), ExecutionCommand::system("pdfcrop"), ); crop.limits_mut() @@ -148,8 +148,7 @@ impl AsyFile { let sender = eval.sender.clone(); move |result| { if !result.status.is_success() { - let mut diagnostic = - Diagnostic::error(format!("Failed to crop pdf of {}", name)); + let mut diagnostic = Diagnostic::error(format!("Failed to crop pdf of {name}")); if result.status.is_internal_error() { diagnostic = diagnostic.with_help("Is 'pdfcrop' installed?"); } @@ -212,16 +211,16 @@ mod tests { local_path: path.join("util.asy"), sandbox_path: PathBuf::from("util.asy"), }; - assert!(deps.contains(&dep), "{:#?} vs {:#?}", deps, dep); + assert!(deps.contains(&dep), "{deps:#?} vs {dep:#?}"); let dep = AsyDependency { local_path: path.join("image.png"), sandbox_path: PathBuf::from("image.png"), }; - assert!(deps.contains(&dep), "{:#?} vs {:#?}", deps, dep); + assert!(deps.contains(&dep), "{deps:#?} vs {dep:#?}"); let dep = AsyDependency { local_path: path.join("assets/wow.txt"), sandbox_path: PathBuf::from("assets/wow.txt"), }; - assert!(deps.contains(&dep), "{:#?} vs {:#?}", deps, dep); + assert!(deps.contains(&dep), "{deps:#?} vs {dep:#?}"); } } diff --git a/task-maker-format/src/ioi/statement/mod.rs b/task-maker-format/src/ioi/statement/mod.rs index 3076e6d95..0a68f7ec1 100644 --- a/task-maker-format/src/ioi/statement/mod.rs +++ b/task-maker-format/src/ioi/statement/mod.rs @@ -103,7 +103,7 @@ pub fn make_task_booklets( for (language, path) in statements { let dest = path.with_extension("pdf"); let statement = Statement::new(path, config.clone()) - .with_context(|| format!("Failed to build statement for language {}", language))?; + .with_context(|| format!("Failed to build statement for language {language}"))?; let booklet_config = BookletConfig::from_contest( language, task.path @@ -160,13 +160,13 @@ pub fn make_contest_booklets( let booklet_config = BookletConfig::from_contest(&language, contest_dir, eval_config.booklet_solutions) .context("Failed to build booklet contest configuration")?; - let dest = contest_dir.join(format!("{}.pdf", language)); + let dest = contest_dir.join(format!("{language}.pdf")); let mut booklet = Booklet::new(booklet_config, dest); for (task, path) in tasks { let config = StatementConfig::from_task(task); let statement = Statement::new(path, config) - .with_context(|| format!("Failed to build statement for language {}", language))?; + .with_context(|| format!("Failed to build statement for language {language}"))?; booklet.add_statement(statement)?; } diff --git a/task-maker-format/src/ioi/statement/statement/tex.rs b/task-maker-format/src/ioi/statement/statement/tex.rs index 62c232953..982143380 100644 --- a/task-maker-format/src/ioi/statement/statement/tex.rs +++ b/task-maker-format/src/ioi/statement/statement/tex.rs @@ -95,7 +95,7 @@ impl Language for Tex { for statement in booklet.statements.iter() { let name = &statement.config().name; - let tex = File::new(format!("Source of statement of {}", name)); + let tex = File::new(format!("Source of statement of {name}")); exec.input(&tex, Path::new(&name).join("statement.tex"), false); eval.dag .provide_content(tex, self.build_statement_source(statement).into_bytes()); @@ -158,8 +158,8 @@ impl Language for Tex { )?; if eval.dag.data.config.copy_logs { let log_dir = eval.task_root.join("bin/logs/booklets"); - let stderr_dest = log_dir.join(format!("{}.stderr.log", booklet_name)); - let stdout_dest = log_dir.join(format!("{}.stdout.log", booklet_name)); + let stderr_dest = log_dir.join(format!("{booklet_name}.stderr.log")); + let stdout_dest = log_dir.join(format!("{booklet_name}.stdout.log")); eval.dag .write_file_to_allow_fail(exec.stderr(), stderr_dest, false); eval.dag @@ -276,7 +276,7 @@ impl Language for Tex { .sorted() .map(|(line, error)| { if let Some(line) = line { - format!("Line {}: {}", line, error) + format!("Line {line}: {error}") } else { error } diff --git a/task-maker-format/src/ioi/statement/statement/typst.rs b/task-maker-format/src/ioi/statement/statement/typst.rs index af916b8da..bc39b8e0c 100644 --- a/task-maker-format/src/ioi/statement/statement/typst.rs +++ b/task-maker-format/src/ioi/statement/statement/typst.rs @@ -71,7 +71,7 @@ impl Language for Typst { for statement in booklet.statements.iter() { let name = &statement.config().name; - let typst = File::new(format!("Source of statement of {}", name)); + let typst = File::new(format!("Source of statement of {name}")); exec.input( &typst, Path::new(&name).join("statement/statement.typ"), @@ -80,7 +80,7 @@ impl Language for Typst { eval.dag .provide_content(typst, self.build_statement_source(statement).into_bytes()); - let task_yaml = File::new(format!("task.yaml for {}", name)); + let task_yaml = File::new(format!("task.yaml for {name}")); exec.input(&task_yaml, Path::new(&name).join("task.yaml"), false); eval.dag.provide_content( task_yaml, @@ -140,8 +140,8 @@ impl Language for Typst { )?; if eval.dag.data.config.copy_logs { let log_dir = eval.task_root.join("bin/logs/booklets"); - let stderr_dest = log_dir.join(format!("{}.stderr.log", booklet_name)); - let stdout_dest = log_dir.join(format!("{}.stdout.log", booklet_name)); + let stderr_dest = log_dir.join(format!("{booklet_name}.stderr.log")); + let stdout_dest = log_dir.join(format!("{booklet_name}.stdout.log")); eval.dag .write_file_to_allow_fail(exec.stderr(), stderr_dest, false); eval.dag @@ -181,7 +181,7 @@ impl Language for Typst { .join("\n"); if booklet.config.intro_page.is_some() { - format!("#include \"intro_page.typ\"\n{}", statements) + format!("#include \"intro_page.typ\"\n{statements}") } else { statements } diff --git a/task-maker-format/src/terry/curses_ui.rs b/task-maker-format/src/terry/curses_ui.rs index c0de237f5..b9ac06453 100644 --- a/task-maker-format/src/terry/curses_ui.rs +++ b/task-maker-format/src/terry/curses_ui.rs @@ -152,7 +152,7 @@ fn evaluation_line<'a>(state: &SolutionState) -> Vec> { SolutionStatus::Solved => vec![Span::raw("Solved")], SolutionStatus::Checking => vec![Span::raw("Checking")], SolutionStatus::Done => evaluation_outcome(state.outcome.as_ref()), - SolutionStatus::Failed(e) => vec![Span::raw(format!("Failed: {}", e))], + SolutionStatus::Failed(e) => vec![Span::raw(format!("Failed: {e}"))], SolutionStatus::Skipped => vec![Span::raw("Skipped")], } } @@ -182,7 +182,7 @@ fn evaluation_outcome<'a>(outcome: Option<&Result>) -> } res } - Some(Err(e)) => vec![Span::raw(format!("Checker failed: {}", e))], + Some(Err(e)) => vec![Span::raw(format!("Checker failed: {e}"))], None => vec![Span::raw("unknown")], } } @@ -197,7 +197,7 @@ fn evaluation_score<'a>(max_score: f64, state: &SolutionState, loading: char) -> | SolutionStatus::Validated | SolutionStatus::Solving | SolutionStatus::Solved - | SolutionStatus::Checking => Span::raw(format!(" {} ", loading)), + | SolutionStatus::Checking => Span::raw(format!(" {loading} ")), SolutionStatus::Done => { if let Some(Ok(outcome)) = &state.outcome { let score = format!("{:>3.0}", outcome.score * max_score); @@ -209,7 +209,7 @@ fn evaluation_score<'a>(max_score: f64, state: &SolutionState, loading: char) -> Span::styled(score, *YELLOW) } } else { - Span::raw(format!(" {} ", loading)) + Span::raw(format!(" {loading} ")) } } SolutionStatus::Failed(_) | SolutionStatus::Skipped => Span::raw(" X "), diff --git a/task-maker-format/src/terry/finish_ui.rs b/task-maker-format/src/terry/finish_ui.rs index 13da1ba82..c4c7ed534 100644 --- a/task-maker-format/src/terry/finish_ui.rs +++ b/task-maker-format/src/terry/finish_ui.rs @@ -62,14 +62,14 @@ impl FinishUI { Some(Err(e)) => { println!(); cwrite!(self, RED, "Fail: "); - println!("{}", e); + println!("{e}"); } None => { println!(); } } if let Some(seed) = solution.seed { - println!(" Seed: {}", seed); + println!(" Seed: {seed}"); } let print_result = |result: &Option| { @@ -126,7 +126,7 @@ impl FinishUI { let content = content.trim(); if !content.is_empty() { cwriteln!(self, YELLOW, "Stderr:"); - println!("{}", content); + println!("{content}"); } } } @@ -145,7 +145,7 @@ impl FinishUI { .zip(evaluation_results) .enumerate() { - print!("#{:<3} ", index); + print!("#{index:<3} "); match val.status { CaseStatus::Missing => cwrite!(self, YELLOW, "Missing"), CaseStatus::Parsed => cwrite!(self, GREEN, " Valid "), @@ -158,10 +158,10 @@ impl FinishUI { cwrite!(self, RED, "Wrong "); } if let Some(message) = &val.message { - print!(" | {}", message); + print!(" | {message}"); } if let Some(message) = &feedback.message { - print!(" | {}", message); + print!(" | {message}"); } println!(); } @@ -179,7 +179,7 @@ impl FinishUI { let evaluation_results = &outcome.feedback.cases; for (index, subtask) in subtasks.iter().enumerate() { - print!("Subtask #{:<2} ", index); + print!("Subtask #{index:<2} "); if abs_diff_eq!(subtask.score, 0.0) { cwrite!( @@ -261,11 +261,11 @@ impl FinishUI { } } Some(Err(e)) => { - print!(" {}", e); + print!(" {e}"); } None => { if let SolutionStatus::Failed(e) = &solution.status { - print!(" {}", e); + print!(" {e}"); } else { print!(" Failed"); } diff --git a/task-maker-format/src/terry/format/mod.rs b/task-maker-format/src/terry/format/mod.rs index 29ff1db58..79eb45a94 100644 --- a/task-maker-format/src/terry/format/mod.rs +++ b/task-maker-format/src/terry/format/mod.rs @@ -94,7 +94,7 @@ fn get_statement_template(task_dir: &Path) -> Result, Error> { fn get_manager(task_dir: &Path, manager: &str) -> Result>, Error> { let mut managers = find_source_file( task_dir, - vec![&format!("managers/{}.*", manager)], + vec![&format!("managers/{manager}.*")], task_dir, "Terry manager at", None, diff --git a/task-maker-format/src/terry/mod.rs b/task-maker-format/src/terry/mod.rs index efd950411..2ffd218d6 100644 --- a/task-maker-format/src/terry/mod.rs +++ b/task-maker-format/src/terry/mod.rs @@ -228,7 +228,7 @@ impl TerryTask { move |outcome| { sender.send(UIMessage::TerrySolutionOutcome { solution: solution_path, - outcome: outcome.map_err(|e| format!("Invalid checker outcome: {}", e)), + outcome: outcome.map_err(|e| format!("Invalid checker outcome: {e}")), }) }, )?; diff --git a/task-maker-format/src/terry/sanity_checks/checker.rs b/task-maker-format/src/terry/sanity_checks/checker.rs index c72057ccc..af473076f 100644 --- a/task-maker-format/src/terry/sanity_checks/checker.rs +++ b/task-maker-format/src/terry/sanity_checks/checker.rs @@ -48,8 +48,7 @@ impl SanityCheck for FuzzChecker { eval.dag.on_execution_done(&gen.uuid, move |res| { if !res.status.is_success() { let mut diagnostic = Diagnostic::error(format!( - "Failed to generate input for FuzzChecker with seed {}", - seed + "Failed to generate input for FuzzChecker with seed {seed}" )) .with_note(format!("The generator failed with: {:?}", res.status)); if let Some(stderr) = res.stderr { diff --git a/task-maker-format/src/ui/curses.rs b/task-maker-format/src/ui/curses.rs index a0a7cb2a5..2bebb73f1 100644 --- a/task-maker-format/src/ui/curses.rs +++ b/task-maker-format/src/ui/curses.rs @@ -256,7 +256,7 @@ pub(crate) fn draw_compilations<'a, I>( pub(crate) fn compilation_status_text(status: &CompilationStatus, loading: char) -> Span<'static> { match status { CompilationStatus::Pending => Span::raw("... "), - CompilationStatus::Running => Span::raw(format!("{} ", loading)), + CompilationStatus::Running => Span::raw(format!("{loading} ")), CompilationStatus::Done { .. } => Span::styled("OK ", *GREEN), CompilationStatus::Failed { .. } => Span::styled("FAIL", *RED), CompilationStatus::Skipped => Span::styled("skip", *YELLOW), @@ -405,7 +405,7 @@ fn draw_workers_chunk( } else { let job_name: String = line.chars().take(job.job.len() - extra_len - 3).collect(); - line = format!("{} {}... ({:.2}s)", loading, job_name, duration); + line = format!("{loading} {job_name}... ({duration:.2}s)"); } } spans.push(Span::raw(line)); diff --git a/task-maker-format/src/ui/json.rs b/task-maker-format/src/ui/json.rs index f60f47281..53b5c48a5 100644 --- a/task-maker-format/src/ui/json.rs +++ b/task-maker-format/src/ui/json.rs @@ -14,7 +14,7 @@ impl JsonUI { impl UI for JsonUI { fn on_message(&mut self, message: UIMessage) { let message = serde_json::to_string(&message).expect("Failed to serialize message"); - println!("{}", message); + println!("{message}"); } fn finish(&mut self) {} diff --git a/task-maker-format/src/ui/mod.rs b/task-maker-format/src/ui/mod.rs index a5041ac56..459e768d4 100644 --- a/task-maker-format/src/ui/mod.rs +++ b/task-maker-format/src/ui/mod.rs @@ -284,13 +284,13 @@ impl<'a> FinishUIUtils<'a> { pub fn print_fail_execution_status(status: &ExecutionStatus) { match status { ExecutionStatus::Success => {} - ExecutionStatus::ReturnCode(code) => print!("Exited with {}", code), - ExecutionStatus::Signal(sig, name) => print!("Signal {} ({})", sig, name), + ExecutionStatus::ReturnCode(code) => print!("Exited with {code}"), + ExecutionStatus::Signal(sig, name) => print!("Signal {sig} ({name})"), ExecutionStatus::TimeLimitExceeded => print!("Time limit exceeded"), ExecutionStatus::SysTimeLimitExceeded => print!("Kernel time limit exceeded"), ExecutionStatus::WallTimeLimitExceeded => print!("Wall time limit exceeded"), ExecutionStatus::MemoryLimitExceeded => print!("Memory limit exceeded"), - ExecutionStatus::InternalError(err) => print!("Internal error: {}", err), + ExecutionStatus::InternalError(err) => print!("Internal error: {err}"), } } @@ -308,7 +308,7 @@ impl<'a> FinishUIUtils<'a> { let diagnostics = diagnostics.diagnostics(); if !diagnostics.is_empty() { for diagnostic in diagnostics.iter().sorted_by_key(|d| d.level()) { - println!("{}", diagnostic); + println!("{diagnostic}"); } } } @@ -366,7 +366,7 @@ impl std::str::FromStr for UIType { "curses" => Ok(UIType::Curses), "json" => Ok(UIType::Json), "silent" => Ok(UIType::Silent), - _ => Err(format!("Unknown ui: {}", s)), + _ => Err(format!("Unknown ui: {s}")), } } } diff --git a/task-maker-format/src/ui/print.rs b/task-maker-format/src/ui/print.rs index 50525d32f..a039090bb 100644 --- a/task-maker-format/src/ui/print.rs +++ b/task-maker-format/src/ui/print.rs @@ -47,7 +47,7 @@ impl PrintUI { match status { UIExecutionStatus::Pending => {} UIExecutionStatus::Started { worker } => { - print!("Worker: {:?}", worker); + print!("Worker: {worker:?}"); } UIExecutionStatus::Done { result } => { self.write_execution_status(&result.status); @@ -67,7 +67,7 @@ impl PrintUI { /// Write a message, padding it to at least 80 chars. fn write_message(&mut self, message: String) { - print!("{:<80}", message); + print!("{message:<80}"); } } @@ -98,17 +98,17 @@ impl UI for PrintUI { } UIMessage::Compilation { file, status } => { self.write_status(&status); - self.write_message(format!("Compilation of {:?} ", file)); + self.write_message(format!("Compilation of {file:?} ")); self.write_status_details(&status); if let UIExecutionStatus::Done { result } = status { if let Some(stderr) = result.stderr { let stderr = String::from_utf8_lossy(&stderr); - println!("\n[STDERR] Compilation stderr of {:?}", file); + println!("\n[STDERR] Compilation stderr of {file:?}"); print!("{}", stderr.trim()); } if let Some(stdout) = result.stdout { let stdout = String::from_utf8_lossy(&stdout); - println!("\n[STDOUT] Compilation stdout of {:?}", file); + println!("\n[STDOUT] Compilation stdout of {file:?}"); print!("{}", stdout.trim()); } } @@ -121,7 +121,7 @@ impl UI for PrintUI { println!(" {}: {} points", st_num, subtask.max_score); print!(" testcases: ["); for tc_num in subtask.testcases_owned.iter().sorted() { - print!(" {}", tc_num); + print!(" {tc_num}"); } println!(" ]"); } @@ -133,16 +133,14 @@ impl UI for PrintUI { } => { self.write_status(&status); self.write_message(format!( - "Generation of testcase {} of subtask {} ", - testcase, subtask + "Generation of testcase {testcase} of subtask {subtask} " )); self.write_status_details(&status); if let UIExecutionStatus::Done { result } = status { if let Some(stderr) = result.stderr { let stderr = String::from_utf8_lossy(&stderr); println!( - "\n[STDERR] Generation stderr of testcase {} of subtask {}", - testcase, subtask + "\n[STDERR] Generation stderr of testcase {testcase} of subtask {subtask}" ); print!("{}", stderr.trim()); } @@ -155,16 +153,14 @@ impl UI for PrintUI { } => { self.write_status(&status); self.write_message(format!( - "Validation of testcase {} of subtask {} ", - testcase, subtask + "Validation of testcase {testcase} of subtask {subtask} " )); self.write_status_details(&status); if let UIExecutionStatus::Done { result } = status { if let Some(stderr) = result.stderr { let stderr = String::from_utf8_lossy(&stderr); println!( - "\n[STDERR] Validation stderr of testcase {} of subtask {}", - testcase, subtask + "\n[STDERR] Validation stderr of testcase {testcase} of subtask {subtask}" ); print!("{}", stderr.trim()); } @@ -177,8 +173,7 @@ impl UI for PrintUI { } => { self.write_status(&status); self.write_message(format!( - "Solution of testcase {} of subtask {} ", - testcase, subtask + "Solution of testcase {testcase} of subtask {subtask} " )); self.write_status_details(&status); } @@ -209,8 +204,7 @@ impl UI for PrintUI { } => { self.write_status(&status); self.write_message(format!( - "Checking output of {:?} of testcase {} of subtask {} ", - solution, testcase, subtask + "Checking output of {solution:?} of testcase {testcase} of subtask {subtask} " )); } UIMessage::IOITestcaseScore { @@ -222,8 +216,7 @@ impl UI for PrintUI { } => { print!("[TESTCAS] "); self.write_message(format!( - "Solution {:?} scored {} on testcase {} of subtask {}: {}", - solution, score, testcase, subtask, message + "Solution {solution:?} scored {score} on testcase {testcase} of subtask {subtask}: {message}" )); } UIMessage::IOISubtaskScore { @@ -234,17 +227,16 @@ impl UI for PrintUI { } => { print!("[SUBTASK] "); self.write_message(format!( - "Solution {:?} scored {} on subtask {} (normalized score {})", - solution, score, subtask, normalized_score, + "Solution {solution:?} scored {score} on subtask {subtask} (normalized score {normalized_score})", )); } UIMessage::IOITaskScore { solution, score } => { print!("[TASK] "); - self.write_message(format!("Solution {:?} scored {} ", solution, score)); + self.write_message(format!("Solution {solution:?} scored {score} ")); } UIMessage::IOIBooklet { name, status } => { self.write_status(&status); - self.write_message(format!("Compilation of booklet {}", name)); + self.write_message(format!("Compilation of booklet {name}")); } UIMessage::IOIBookletDependency { booklet, @@ -264,7 +256,7 @@ impl UI for PrintUI { } UIMessage::Diagnostic { diagnostic } => { println!("[DIAGNOSTIC]"); - println!("{}", diagnostic); + println!("{diagnostic}"); } UIMessage::TerryTask { .. } => {} UIMessage::TerryGeneration { diff --git a/task-maker-format/src/ui/raw.rs b/task-maker-format/src/ui/raw.rs index 13cee18fe..864dbb241 100644 --- a/task-maker-format/src/ui/raw.rs +++ b/task-maker-format/src/ui/raw.rs @@ -14,7 +14,7 @@ impl RawUI { impl UI for RawUI { fn on_message(&mut self, message: UIMessage) { - println!("{:?}", message); + println!("{message:?}"); } fn finish(&mut self) { diff --git a/task-maker-format/tests/ioi_sanity_checks.rs b/task-maker-format/tests/ioi_sanity_checks.rs index d162b2483..96a8ebd1d 100644 --- a/task-maker-format/tests/ioi_sanity_checks.rs +++ b/task-maker-format/tests/ioi_sanity_checks.rs @@ -37,13 +37,13 @@ fn has_warning(warnings: &[String], warning: &str) { return; } } - panic!("{:?} does not contain {:?}", warnings, warning); + panic!("{warnings:?} does not contain {warning:?}"); } fn does_not_have_warning(warnings: &[String], warning: &str) { for warn in warnings { if warn.contains(warning) { - panic!("{:?} contains {:?}", warnings, warning); + panic!("{warnings:?} contains {warning:?}"); } } } diff --git a/task-maker-format/tests/ioi_task_clean.rs b/task-maker-format/tests/ioi_task_clean.rs index 209c572ae..ef4854c5f 100644 --- a/task-maker-format/tests/ioi_task_clean.rs +++ b/task-maker-format/tests/ioi_task_clean.rs @@ -14,8 +14,8 @@ fn test_ioi_task_clean() { std::fs::create_dir(&input).unwrap(); std::fs::create_dir(&output).unwrap(); for i in 0..3 { - std::fs::write(input.join(format!("input{}.txt", i)), "x").unwrap(); - std::fs::write(output.join(format!("output{}.txt", i)), "x").unwrap(); + std::fs::write(input.join(format!("input{i}.txt")), "x").unwrap(); + std::fs::write(output.join(format!("output{i}.txt")), "x").unwrap(); } task.clean().unwrap(); assert!(!input.exists()); @@ -31,8 +31,8 @@ fn test_ioi_task_clean_skip_static() { std::fs::create_dir(&input).unwrap(); std::fs::create_dir(&output).unwrap(); for i in 0..3 { - std::fs::write(input.join(format!("input{}.txt", i)), "x").unwrap(); - std::fs::write(output.join(format!("output{}.txt", i)), "x").unwrap(); + std::fs::write(input.join(format!("input{i}.txt")), "x").unwrap(); + std::fs::write(output.join(format!("output{i}.txt")), "x").unwrap(); } task.testcases.get_mut(&0).unwrap().input_generator = InputGenerator::StaticFile(input.join("input0.txt")); diff --git a/task-maker-format/tests/score_manager.rs b/task-maker-format/tests/score_manager.rs index 0f3a5af46..d9fecb5ef 100644 --- a/task-maker-format/tests/score_manager.rs +++ b/task-maker-format/tests/score_manager.rs @@ -34,7 +34,7 @@ fn test_score_manager() { assert_abs_diff_eq!(score, 1.0); assert_eq!(message, "foo"); } - _ => panic!("Expecting UIMessage::IOITestcaseScore but was {:?}", mex), + _ => panic!("Expecting UIMessage::IOITestcaseScore but was {mex:?}"), } } else { panic!("Expecting UIMessage::IOITestcaseScore but was nothing"); @@ -52,7 +52,7 @@ fn test_score_manager() { assert_abs_diff_eq!(score, 10.0); assert_abs_diff_eq!(normalized_score, 1.0); } - _ => panic!("Expecting UIMessage::IOISubtaskScore but was {:?}", mex), + _ => panic!("Expecting UIMessage::IOISubtaskScore but was {mex:?}"), } } else { panic!("Expecting UIMessage::IOISubtaskScore but was nothing"); @@ -77,13 +77,13 @@ fn test_score_manager() { assert_abs_diff_eq!(score, 1.0); assert_eq!(message, "foo"); } - _ => panic!("Expecting UIMessage::IOITestcaseScore but was {:?}", mex), + _ => panic!("Expecting UIMessage::IOITestcaseScore but was {mex:?}"), } } else { panic!("Expecting UIMessage::IOITestcaseScore but was nothing"); } if let Ok(mex) = receiver.try_recv() { - panic!("Expecting nothing but was {:?}", mex); + panic!("Expecting nothing but was {mex:?}"); } manager.score(1, 2, 0.0, "foo".into(), sender).unwrap(); @@ -102,7 +102,7 @@ fn test_score_manager() { assert_abs_diff_eq!(score, 0.0); assert_eq!(message, "foo"); } - _ => panic!("Expecting UIMessage::IOITestcaseScore but was {:?}", mex), + _ => panic!("Expecting UIMessage::IOITestcaseScore but was {mex:?}"), } } else { panic!("Expecting UIMessage::IOITestcaseScore but was nothing"); @@ -120,7 +120,7 @@ fn test_score_manager() { assert_abs_diff_eq!(score, 0.0); assert_abs_diff_eq!(normalized_score, 0.0); } - _ => panic!("Expecting UIMessage::IOISubtaskScore but was {:?}", mex), + _ => panic!("Expecting UIMessage::IOISubtaskScore but was {mex:?}"), } } else { panic!("Expecting UIMessage::IOISubtaskScore but was nothing"); @@ -131,7 +131,7 @@ fn test_score_manager() { assert_eq!(solution, PathBuf::from("sol")); assert_abs_diff_eq!(score, 10.0); } - _ => panic!("Expecting UIMessage::IOITaskScore but was {:?}", mex), + _ => panic!("Expecting UIMessage::IOITaskScore but was {mex:?}"), } } else { panic!("Expecting UIMessage::IOITaskScore but was nothing"); @@ -164,7 +164,7 @@ fn test_score_manager_empty_subtask() { assert_abs_diff_eq!(score, 90.0); assert_abs_diff_eq!(normalized_score, 1.0); } - _ => panic!("Expecting UIMessage::IOISubtaskScore but was {:?}", mex), + _ => panic!("Expecting UIMessage::IOISubtaskScore but was {mex:?}"), } } else { panic!("Expecting UIMessage::IOISubtaskScore but was nothing"); @@ -186,7 +186,7 @@ fn test_score_manager_empty_subtask() { assert_abs_diff_eq!(score, 1.0); assert_eq!(message, "foo"); } - _ => panic!("Expecting UIMessage::IOITestcaseScore but was {:?}", mex), + _ => panic!("Expecting UIMessage::IOITestcaseScore but was {mex:?}"), } } else { panic!("Expecting UIMessage::IOITestcaseScore but was nothing"); @@ -204,7 +204,7 @@ fn test_score_manager_empty_subtask() { assert_abs_diff_eq!(score, 10.0); assert_abs_diff_eq!(normalized_score, 1.0); } - _ => panic!("Expecting UIMessage::IOISubtaskScore but was {:?}", mex), + _ => panic!("Expecting UIMessage::IOISubtaskScore but was {mex:?}"), } } else { panic!("Expecting UIMessage::IOISubtaskScore but was nothing"); @@ -215,7 +215,7 @@ fn test_score_manager_empty_subtask() { assert_eq!(solution, PathBuf::from("sol")); assert_abs_diff_eq!(score, 100.0); } - _ => panic!("Expecting UIMessage::IOITaskScore but was {:?}", mex), + _ => panic!("Expecting UIMessage::IOITaskScore but was {mex:?}"), } } else { panic!("Expecting UIMessage::IOITaskScore but was nothing"); diff --git a/task-maker-lang/src/language.rs b/task-maker-lang/src/language.rs index fd688028e..23f9e3182 100644 --- a/task-maker-lang/src/language.rs +++ b/task-maker-lang/src/language.rs @@ -181,7 +181,7 @@ impl<'l, 'c> SimpleCompiledLanguageBuilder<'l, 'c> { .to_string(); // names starting with - can be interpreted as command line options if source_name.starts_with('-') { - source_name = format!("./{}", source_name); + source_name = format!("./{source_name}"); } Self { language, @@ -230,7 +230,7 @@ impl CompiledLanguageBuilder for SimpleCompiledLanguageBuilder<'_, '_> { fn finalize(&mut self, dag: &mut ExecutionDAG) -> Result<(Execution, File), Error> { let name = self.source_path.file_name().unwrap().to_string_lossy(); - let mut comp = Execution::new(format!("Compilation of {}", name), self.compiler.clone()); + let mut comp = Execution::new(format!("Compilation of {name}"), self.compiler.clone()); comp.args.clone_from(&self.args); // compilation dependencies diff --git a/task-maker-lang/src/languages/csharp.rs b/task-maker-lang/src/languages/csharp.rs index 2efea0973..a9274ad8a 100644 --- a/task-maker-lang/src/languages/csharp.rs +++ b/task-maker-lang/src/languages/csharp.rs @@ -49,7 +49,7 @@ impl Language for LanguageCSharp { metadata .add_arg("-define:EVAL") .add_arg("-optimize+") - .add_arg(format!("-out:{}", binary_name)); + .add_arg(format!("-out:{binary_name}")); metadata.callback(move |comp| { comp.limits_mut().add_extra_readable_dir("/etc/mono"); diff --git a/task-maker-lang/src/languages/mod.rs b/task-maker-lang/src/languages/mod.rs index 79b75a7c5..b5b9f03b8 100644 --- a/task-maker-lang/src/languages/mod.rs +++ b/task-maker-lang/src/languages/mod.rs @@ -47,8 +47,7 @@ where pending.push_back(local_path.clone()); result.push(Dependency { file: File::new(format!( - "Dependency {:?} at {:?} of {:?}", - sandbox_path, local_path, filename + "Dependency {sandbox_path:?} at {local_path:?} of {filename:?}" )), local_path, sandbox_path, diff --git a/task-maker-lang/src/languages/pascal.rs b/task-maker-lang/src/languages/pascal.rs index a8c545011..5164266d5 100644 --- a/task-maker-lang/src/languages/pascal.rs +++ b/task-maker-lang/src/languages/pascal.rs @@ -53,7 +53,7 @@ impl Language for LanguagePascal { .add_arg("-Fe/dev/stderr") .add_arg("-O2") .add_arg("-XS") - .add_arg(format!("-o{}", binary_name)); + .add_arg(format!("-o{binary_name}")); if let Some(fpc_cfg) = find_fpc_cfg() { metadata.add_dependency(Dependency { diff --git a/task-maker-lang/src/languages/python.rs b/task-maker-lang/src/languages/python.rs index 59605e2d4..b376503a6 100644 --- a/task-maker-lang/src/languages/python.rs +++ b/task-maker-lang/src/languages/python.rs @@ -169,7 +169,7 @@ mod tests { .unwrap(); let imports = extract_imports(&path); for (i, import) in ["foo", "bar", "baz", "biz"].iter().enumerate() { - let import = PathBuf::from(format!("{}.py", import)); + let import = PathBuf::from(format!("{import}.py")); assert_that(&imports[i]).is_equal_to((import.clone(), import)); } } diff --git a/tests/common/test_interface.rs b/tests/common/test_interface.rs index 538f5289b..95862dbfe 100644 --- a/tests/common/test_interface.rs +++ b/tests/common/test_interface.rs @@ -85,17 +85,11 @@ impl TestInterface { pub fn fail>(self, err: S) { let err = err.as_ref(); if let Err(e) = self.state { - if !format!("{:?}", e).contains(err) { - panic!( - "Expecting task-maker to fail with '{}' but failed with {:?}", - err, e - ); + if !format!("{e:?}").contains(err) { + panic!("Expecting task-maker to fail with '{err}' but failed with {e:?}"); } } else { - panic!( - "Expecting task-maker to fail with '{}' but didn't fail", - err - ); + panic!("Expecting task-maker to fail with '{err}' but didn't fail"); } } @@ -104,7 +98,7 @@ impl TestInterface { pub fn success(self) -> TestInterfaceSuccessful { match self.state { Ok(state) => TestInterfaceSuccessful { state }, - Err(e) => panic!("Expecting task-maker not to fail, but failed with {:?}", e), + Err(e) => panic!("Expecting task-maker not to fail, but failed with {e:?}"), } } @@ -119,7 +113,7 @@ impl TestInterface { ) -> Result { let mut args: Vec<&str> = vec!["task-maker"]; let path = task_dir.to_string_lossy().into_owned(); - let path = format!("--task-dir={}", path); + let path = format!("--task-dir={path}"); args.push(&path); args.push("--ui=silent"); args.push("--num-cores=1"); @@ -196,7 +190,7 @@ impl TestInterface { &format!("unix://{}", client_path.display()), &format!("unix://{}", worker_path.display()), ]); - eprintln!("Server opts {:?}", opt); + eprintln!("Server opts {opt:?}"); main_server(opt).unwrap(); } }) @@ -214,7 +208,7 @@ impl TestInterface { &store, &format!("unix://{}", worker_path.display()), ]); - eprintln!("Worker opts {:?}", opt); + eprintln!("Worker opts {opt:?}"); std::env::set_var( "TASK_MAKER_TOOLS_PATH", env!("CARGO_BIN_EXE_task-maker-tools"), @@ -259,7 +253,7 @@ impl TestInterfaceSuccessful { if let Some(comp) = comp { match comp { CompilationStatus::Done { .. } => {} - _ => panic!("Expecting {:?} to compile, but was: {:?}", source, comp), + _ => panic!("Expecting {source:?} to compile, but was: {comp:?}"), } } else { panic!( @@ -277,10 +271,10 @@ impl TestInterfaceSuccessful { if let Some(comp) = comp { match comp { CompilationStatus::Failed { .. } => {} - _ => panic!("Expecting {:?} not to compile, but was: {:?}", source, comp), + _ => panic!("Expecting {source:?} not to compile, but was: {comp:?}"), } } else { - panic!("Compilation not present: {:?}", source); + panic!("Compilation not present: {source:?}"); } self } @@ -290,10 +284,7 @@ impl TestInterfaceSuccessful { let source = source.into(); let comp = self.get_path_key(&self.state.compilations, &source); if let Some(comp) = comp { - panic!( - "Expecting {:?} not to be compiled, but was {:?}", - source, comp - ); + panic!("Expecting {source:?} not to be compiled, but was {comp:?}"); } self } @@ -306,11 +297,10 @@ impl TestInterfaceSuccessful { for (i, expected) in scores.iter().enumerate() { let actual = subtasks .get(&(i as SubtaskId)) - .unwrap_or_else(|| panic!("Missing subtask {}", i)); + .unwrap_or_else(|| panic!("Missing subtask {i}")); assert!( abs_diff_eq!(actual.max_score, expected), - "Wrong subtask score of subtask {}", - i + "Wrong subtask score of subtask {i}" ); } self @@ -326,17 +316,15 @@ impl TestInterfaceSuccessful { let scores: Vec<_> = scores.into_iter().collect(); let state = self .get_path_key(&self.state.evaluations, &solution) - .unwrap_or_else(|| panic!("No evaluation score for solution {:?}", solution)); + .unwrap_or_else(|| panic!("No evaluation score for solution {solution:?}")); let score: f64 = scores.iter().sum(); let state_score = state .score - .unwrap_or_else(|| panic!("Missing score of {:?}", solution)); + .unwrap_or_else(|| panic!("Missing score of {solution:?}")); assert!( abs_diff_eq!(score, state_score), - "Solution score mismatch for solution {:?}: {:#?}", - solution, - state + "Solution score mismatch for solution {solution:?}: {state:#?}" ); assert_eq!( scores.len(), @@ -347,10 +335,7 @@ impl TestInterfaceSuccessful { let actual = state.subtasks[&(st as SubtaskId)].score.unwrap(); assert!( abs_diff_eq!(*expected, actual), - "Solution subtask score mismatch of solution {:?} at subtask {}: {:#?}", - solution, - st, - state + "Solution subtask score mismatch of solution {solution:?} at subtask {st}: {state:#?}" ); } self @@ -366,7 +351,7 @@ impl TestInterfaceSuccessful { let statuses: Vec<_> = statuses.into_iter().collect(); let actuals = self .get_path_key(&self.state.evaluations, &solution) - .unwrap_or_else(|| panic!("Evaluation status missing for solution {:?}", solution)); + .unwrap_or_else(|| panic!("Evaluation status missing for solution {solution:?}")); let mut id = 0; for st in actuals.subtasks.keys().sorted() { for tc in &self.state.task.subtasks[st].testcases { @@ -374,8 +359,7 @@ impl TestInterfaceSuccessful { let actual = &actuals.testcases[tc].status; assert_eq!( actual, expected, - "Solution status mismatch of {:?} at subtask {}, testcase {}", - solution, st, tc + "Solution status mismatch of {solution:?} at subtask {st}, testcase {tc}" ); if id + 1 < statuses.len() { id += 1; @@ -397,10 +381,7 @@ impl TestInterfaceSuccessful { for tc in subtask.testcases.keys().sorted() { let actual = &subtask.testcases[tc].status; let expected = statuses.get(id).unwrap_or_else(|| { - panic!( - "Too few testcases in provided status, needing at least {}", - id - ) + panic!("Too few testcases in provided status, needing at least {id}") }); assert_eq!(actual, expected); @@ -429,9 +410,7 @@ impl TestInterfaceSuccessful { assert_ne!( &ExecutionStatus::Success, status, - "Expecting generation of subtask {}, testcase {} to fail", - st, - tc + "Expecting generation of subtask {st}, testcase {tc} to fail" ); let stderr = testcase .generation @@ -443,24 +422,17 @@ impl TestInterfaceSuccessful { let stderr = String::from_utf8_lossy(stderr); assert!( stderr.contains(expected), - "Generation stderr of subtask {}, testcase {} does not contain '{}'. It is '{:?}'", - st, tc, expected, stderr + "Generation stderr of subtask {st}, testcase {tc} does not contain '{expected}'. It is '{stderr:?}'" ); } Some(None) => { assert_eq!( &ExecutionStatus::Success, status, - "Expecting generation of subtask {}, testcase {} not to fail, but was: {:?}", - st, - tc, - status + "Expecting generation of subtask {st}, testcase {tc} not to fail, but was: {status:?}" ); } - None => panic!( - "Too few testcases in provided status, needing at least {}", - id - ), + None => panic!("Too few testcases in provided status, needing at least {id}"), } id += 1; } @@ -487,9 +459,7 @@ impl TestInterfaceSuccessful { assert_ne!( &ExecutionStatus::Success, status, - "Expecting validation of subtask {}, testcase {} to fail", - st, - tc + "Expecting validation of subtask {st}, testcase {tc} to fail" ); let stderr = testcase .validation @@ -501,24 +471,17 @@ impl TestInterfaceSuccessful { let stderr = String::from_utf8_lossy(stderr); assert!( stderr.contains(expected), - "Validation stderr of subtask {}, testcase {} does not contain '{}'. It is '{:?}'", - st, tc, expected, stderr + "Validation stderr of subtask {st}, testcase {tc} does not contain '{expected}'. It is '{stderr:?}'" ); } Some(None) => { assert_eq!( &ExecutionStatus::Success, status, - "Expecting validation of subtask {}, testcase {} not to fail, but was: {:?}", - st, - tc, - status + "Expecting validation of subtask {st}, testcase {tc} not to fail, but was: {status:?}" ); } - None => panic!( - "Too few testcases in provided status, needing at least {}", - id - ), + None => panic!("Too few testcases in provided status, needing at least {id}"), } id += 1; } @@ -563,10 +526,7 @@ impl TestInterfaceSuccessful { .iter() .any(|d| d.message().contains(message)) { - panic!( - "Expecting the diagnostics to contain {}, but they don't", - message - ); + panic!("Expecting the diagnostics to contain {message}, but they don't"); } self } @@ -581,10 +541,7 @@ impl TestInterfaceSuccessful { .iter() .any(|d| d.message().contains(message)) { - panic!( - "Expecting the diagnostics not to contain {}, but they do", - message - ); + panic!("Expecting the diagnostics not to contain {message}, but they do"); } self } diff --git a/tests/fifo.rs b/tests/fifo.rs index 0d32f12d1..c994a57e2 100644 --- a/tests/fifo.rs +++ b/tests/fifo.rs @@ -35,7 +35,7 @@ fn test_fifo() { .to_owned(), ); dag.on_execution_done(&exec1.uuid, |res| { - assert!(res.status.is_success(), "Process 1 crashed: {:?}", res); + assert!(res.status.is_success(), "Process 1 crashed: {res:?}"); Ok(()) }); dag.on_execution_skip(&exec1.uuid, || panic!("Process 1 has been skipped")); @@ -60,7 +60,7 @@ fn test_fifo() { .to_owned(), ); dag.on_execution_done(&exec2.uuid, |res| { - assert!(res.status.is_success(), "Process 2 crashed: {:?}", res); + assert!(res.status.is_success(), "Process 2 crashed: {res:?}"); Ok(()) }); dag.on_execution_skip(&exec2.uuid, || panic!("Process 2 has been skipped")); diff --git a/tests/sandbox.rs b/tests/sandbox.rs index f839b296f..bebef7c79 100644 --- a/tests/sandbox.rs +++ b/tests/sandbox.rs @@ -15,7 +15,7 @@ fn test_remove_output_file() { .output("file1"); dag.on_execution_done(&exec.uuid, |res| { - assert!(!res.status.is_success(), "rm didn't fail: {:?}", res); + assert!(!res.status.is_success(), "rm didn't fail: {res:?}"); Ok(()) }); dag.add_execution(exec); @@ -35,7 +35,7 @@ fn test_chmod_dir() { .output("file1"); dag.on_execution_done(&exec.uuid, |res| { - assert!(!res.status.is_success(), "chmod didn't fail: {:?}", res); + assert!(!res.status.is_success(), "chmod didn't fail: {res:?}"); Ok(()) }); dag.add_execution(exec); @@ -53,7 +53,7 @@ fn test_create_files() { .capture_stderr(1000); dag.on_execution_done(&exec.uuid, |res| { - assert!(!res.status.is_success(), "touch didn't fail: {:?}", res); + assert!(!res.status.is_success(), "touch didn't fail: {res:?}"); Ok(()) }); dag.add_execution(exec); @@ -76,7 +76,7 @@ fn test_list_fifo() { .output("file1"); dag.on_execution_done(&exec.uuid, |res| { - assert!(!res.status.is_success(), "ls didn't fail: {:?}", res); + assert!(!res.status.is_success(), "ls didn't fail: {res:?}"); Ok(()) }); dag.add_execution(exec);