refactor: run cargo fmt --all

This commit is contained in:
2026-04-10 14:33:48 +08:00
parent 03f72adade
commit 613fbc6a6a
4 changed files with 15 additions and 6 deletions

View File

@@ -2,7 +2,7 @@ use crate::config::FILE_MAIN_C;
use crate::core::config::Config; use crate::core::config::Config;
use crate::utils::fs::check_dir; use crate::utils::fs::check_dir;
use crate::utils::log::{error, warn}; use crate::utils::log::{error, warn};
use crate::utils::text::{colored, printc, BOLD_CYAN, BOLD_GREEN}; use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
use std::fs; use std::fs;
use std::io::Write; use std::io::Write;
use toml::Value; use toml::Value;

View File

@@ -2,7 +2,7 @@ use crate::config::FILE_MAIN_C;
use crate::core::config::Config; use crate::core::config::Config;
use crate::utils::fs::check_dir; use crate::utils::fs::check_dir;
use crate::utils::log::{error, warn}; use crate::utils::log::{error, warn};
use crate::utils::text::{colored, printc, BOLD_CYAN, BOLD_GREEN}; use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
use std::fs; use std::fs;
use std::io::Write; use std::io::Write;
use toml::Value; use toml::Value;

View File

@@ -80,8 +80,14 @@ fn run_testsuite() -> Result<i32, String> {
} }
let config = Config::open("./dcr.toml").map_err(|_| "Failed to read dcr.toml".to_string())?; let config = Config::open("./dcr.toml").map_err(|_| "Failed to read dcr.toml".to_string())?;
let name = config.get("package.name").and_then(|v| v.as_str()).ok_or("package.name not found in dcr.toml")?; let name = config
let kind = config.get("package.kind").and_then(|v| v.as_str()).unwrap_or("bin"); .get("package.name")
.and_then(|v| v.as_str())
.ok_or("package.name not found in dcr.toml")?;
let kind = config
.get("package.kind")
.and_then(|v| v.as_str())
.unwrap_or("bin");
let compiler = env::var("DCR_CC").unwrap_or_else(|_| "cc".to_string()); let compiler = env::var("DCR_CC").unwrap_or_else(|_| "cc".to_string());
let profile = "release"; let profile = "release";
@@ -108,7 +114,10 @@ fn run_testsuite() -> Result<i32, String> {
// Link // Link
let bin_path = format!("./tests/test{}", std::env::consts::EXE_SUFFIX); let bin_path = format!("./tests/test{}", std::env::consts::EXE_SUFFIX);
let link_cmd = if kind == "lib" { let link_cmd = if kind == "lib" {
format!("{} {} -o {} -Ltarget/release -l{}", compiler, obj_path, bin_path, name) format!(
"{} {} -o {} -Ltarget/release -l{}",
compiler, obj_path, bin_path, name
)
} else { } else {
format!("{} {} -o {}", compiler, obj_path, bin_path) format!("{} {} -o {}", compiler, obj_path, bin_path)
}; };

View File

@@ -1,7 +1,7 @@
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::Command; use std::process::Command;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Once; use std::sync::Once;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::time::{SystemTime, UNIX_EPOCH}; use std::time::{SystemTime, UNIX_EPOCH};
static COUNTER: AtomicUsize = AtomicUsize::new(0); static COUNTER: AtomicUsize = AtomicUsize::new(0);