From 1fb175297d7bdf03187f2399cb7404962954ed39 Mon Sep 17 00:00:00 2001 From: Mark Dittmer Date: Fri, 22 May 2026 19:05:47 +0000 Subject: [PATCH] SQUASH ME: Add copyright/licenses to rust code; drop skipping behaviour from charon invocaitons loop; light code cleanup; a little documentation for generated test helper gherrit-pr-id: Goufr43flofh44irghlel27f3x3o7spbk --- anneal/v2/src/charon.rs | 13 +++++++++---- anneal/v2/src/diagnostics.rs | 9 +++++++++ anneal/v2/src/main.rs | 28 ++++++++++++---------------- anneal/v2/src/parse.rs | 9 +++++++++ anneal/v2/src/resolve.rs | 9 +++++++++ anneal/v2/src/scanner.rs | 9 +++++++++ anneal/v2/src/setup.rs | 9 +++++++++ anneal/v2/src/util.rs | 9 +++++++++ anneal/v2/tests/integration.rs | 9 +++++++++ 9 files changed, 84 insertions(+), 20 deletions(-) diff --git a/anneal/v2/src/charon.rs b/anneal/v2/src/charon.rs index a95ffb4725..2b360eebb5 100644 --- a/anneal/v2/src/charon.rs +++ b/anneal/v2/src/charon.rs @@ -1,3 +1,12 @@ +// Copyright 2026 The Fuchsia Authors +// +// Licensed under the 2-Clause BSD License , Apache License, Version 2.0 +// , or the MIT +// license , at your option. +// This file may not be copied, modified, or distributed except according to +// those terms. + //! Orchestration of Charon extraction. //! //! This module handles the invocation of the `charon` tool to extract @@ -58,10 +67,6 @@ pub fn run_charon( }; packages.par_iter().try_for_each(|artifact| { - if artifact.start_from.is_empty() { - return Ok(()); - } - let pb = mp.as_ref().map(|m| { let pb = m.add(indicatif::ProgressBar::new_spinner()); pb.set_style( diff --git a/anneal/v2/src/diagnostics.rs b/anneal/v2/src/diagnostics.rs index fa65c6d0c6..207ea567c9 100644 --- a/anneal/v2/src/diagnostics.rs +++ b/anneal/v2/src/diagnostics.rs @@ -1,3 +1,12 @@ +// Copyright 2026 The Fuchsia Authors +// +// Licensed under the 2-Clause BSD License , Apache License, Version 2.0 +// , or the MIT +// license , at your option. +// This file may not be copied, modified, or distributed except according to +// those terms. + // Handling of Lean diagnostics and error mapping. // // This module provides the [`crate::diagnostics::DiagnosticMapper`] struct, which is responsible diff --git a/anneal/v2/src/main.rs b/anneal/v2/src/main.rs index b29b79f5ec..42f8d2735e 100644 --- a/anneal/v2/src/main.rs +++ b/anneal/v2/src/main.rs @@ -7,6 +7,7 @@ // This file may not be copied, modified, or distributed except according to // those terms. +use anyhow::Context as _; use clap::Parser as _; mod charon; @@ -35,12 +36,16 @@ enum Commands { /// Helper to acquire shared or exclusive locks for multi-process integration testing (dev only) #[cfg(feature = "exocrate_tests")] TestLockHelper { + /// The role to run as: 'reader-a', 'reader-b', 'writer-a', or 'reader-exclusion' #[arg(long)] role: String, + /// Path to the directory to lock #[arg(long)] lock_dir: std::path::PathBuf, + /// Path to the shared log file where lock transitions are appended #[arg(long)] log_file: std::path::PathBuf, + /// Path to the temporary synchronization signal file #[arg(long)] sig_file: std::path::PathBuf, }, @@ -67,9 +72,9 @@ pub struct ExpandArgs { pub no_progress: bool, } -fn setup(args: SetupArgs) { +fn setup(args: SetupArgs) -> anyhow::Result<()> { crate::setup::run_setup(crate::setup::SetupArgs { local_archive: args.local_archive }) - .expect("failed to setup toolchain"); + .context("Failed to setup toolchain") } fn expand(args: ExpandArgs) -> anyhow::Result<()> { @@ -95,7 +100,7 @@ fn expand(args: ExpandArgs) -> anyhow::Result<()> { Ok(()) } -fn main() { +fn main() -> anyhow::Result<()> { // Suppressing timestamps removes a source of nondeterminism that is // difficult to work around in integration tests. env_logger::builder().format_timestamp(None).init(); @@ -110,21 +115,11 @@ fn main() { match args.command { Commands::Setup(args) => setup(args), - Commands::Expand(args) => { - if let Err(e) = expand(args) { - eprintln!("Error: {:?}", e); - std::process::exit(1); - } - } + Commands::Expand(args) => expand(args), #[cfg(feature = "exocrate_tests")] Commands::TestLockHelper { role, lock_dir, log_file, sig_file } => { - if let Err(e) = - crate::util::run_test_lock_helper(&role, &lock_dir, &log_file, &sig_file) - { - eprintln!("TestLockHelper failed: {:?}", e); - std::process::exit(1); - } + crate::util::run_test_lock_helper(&role, &lock_dir, &log_file, &sig_file) } } } @@ -139,7 +134,8 @@ mod tests { // ASSUMPTION: Dependency builder installs archive at // `target/anneal-exocrate.tar.zst`. local_archive: Some("target/anneal-exocrate.tar.zst".into()), - }); + }) + .expect("Failed to run setup"); // 2. Once setup completes successfully, resolve the toolchain. let toolchain = crate::setup::Toolchain::resolve().expect("Failed to resolve toolchain"); diff --git a/anneal/v2/src/parse.rs b/anneal/v2/src/parse.rs index 0750d9d65b..2507fa8e28 100644 --- a/anneal/v2/src/parse.rs +++ b/anneal/v2/src/parse.rs @@ -1,3 +1,12 @@ +// Copyright 2026 The Fuchsia Authors +// +// Licensed under the 2-Clause BSD License , Apache License, Version 2.0 +// , or the MIT +// license , at your option. +// This file may not be copied, modified, or distributed except according to +// those terms. + pub mod hkd { pub struct Safe; pub trait ThreadSafety {} diff --git a/anneal/v2/src/resolve.rs b/anneal/v2/src/resolve.rs index e60d363e5a..0fc99abf86 100644 --- a/anneal/v2/src/resolve.rs +++ b/anneal/v2/src/resolve.rs @@ -1,3 +1,12 @@ +// Copyright 2026 The Fuchsia Authors +// +// Licensed under the 2-Clause BSD License , Apache License, Version 2.0 +// , or the MIT +// license , at your option. +// This file may not be copied, modified, or distributed except according to +// those terms. + use anyhow::Context as _; use sha2::Digest as _; diff --git a/anneal/v2/src/scanner.rs b/anneal/v2/src/scanner.rs index bda966e159..730d9b1e68 100644 --- a/anneal/v2/src/scanner.rs +++ b/anneal/v2/src/scanner.rs @@ -1,3 +1,12 @@ +// Copyright 2026 The Fuchsia Authors +// +// Licensed under the 2-Clause BSD License , Apache License, Version 2.0 +// , or the MIT +// license , at your option. +// This file may not be copied, modified, or distributed except according to +// those terms. + use sha2::Digest as _; pub struct AnnealArtifact { diff --git a/anneal/v2/src/setup.rs b/anneal/v2/src/setup.rs index 2906d102cd..11b6c4440e 100644 --- a/anneal/v2/src/setup.rs +++ b/anneal/v2/src/setup.rs @@ -1,3 +1,12 @@ +// Copyright 2026 The Fuchsia Authors +// +// Licensed under the 2-Clause BSD License , Apache License, Version 2.0 +// , or the MIT +// license , at your option. +// This file may not be copied, modified, or distributed except according to +// those terms. + use anyhow::Context as _; pub struct SetupArgs { diff --git a/anneal/v2/src/util.rs b/anneal/v2/src/util.rs index 22d9c2be88..fd35f313d2 100644 --- a/anneal/v2/src/util.rs +++ b/anneal/v2/src/util.rs @@ -1,3 +1,12 @@ +// Copyright 2026 The Fuchsia Authors +// +// Licensed under the 2-Clause BSD License , Apache License, Version 2.0 +// , or the MIT +// license , at your option. +// This file may not be copied, modified, or distributed except according to +// those terms. + use anyhow::Context as _; use fs2::FileExt as _; use std::io::BufRead as _; diff --git a/anneal/v2/tests/integration.rs b/anneal/v2/tests/integration.rs index 9ffa413b4a..fe776703ea 100644 --- a/anneal/v2/tests/integration.rs +++ b/anneal/v2/tests/integration.rs @@ -1,3 +1,12 @@ +// Copyright 2026 The Fuchsia Authors +// +// Licensed under the 2-Clause BSD License , Apache License, Version 2.0 +// , or the MIT +// license , at your option. +// This file may not be copied, modified, or distributed except according to +// those terms. + use std::fs; use std::process::Command;