style: 自动格式化

This commit is contained in:
2026-10-11 12:07:58 +00:00
parent f9011ae28c
commit 38e599bac2
2 changed files with 26 additions and 16 deletions
+1 -3
View File
@@ -139,9 +139,7 @@ fn demote_top_level_lexical(source: &str) -> String {
///
/// `demote` 为真时把顶层 let/const 降级为 var(供两模块方案跨 run 共享),
/// 为假时保留原样(供单模块方案,同模块内 let/const 本可见)。
fn build_harness_source(
meta: &TestMeta, harness: &HarnessSources, demote: bool,
) -> Result<String, String> {
fn build_harness_source(meta: &TestMeta, harness: &HarnessSources, demote: bool) -> Result<String, String> {
let mut source = String::new();
// onlyStrict 测试在严格模式下运行:指令必须位于脚本最前(harness 之前)。
if meta.flags.iter().any(|f| f == "onlyStrict") {
+25 -13
View File
@@ -6,8 +6,7 @@
use crate::discovery::{eval_family_excluded, is_skipped, pre_existing_excluded};
use crate::harness::{
append_source_chunk, get_harness_module, get_harness_prefix, HarnessModuleCache,
HarnessPrefixCache, HarnessSources,
append_source_chunk, get_harness_module, get_harness_prefix, HarnessModuleCache, HarnessPrefixCache, HarnessSources,
};
use crate::judge::{
classify_compile_error, judge_async_result, judge_vm_error, panic_payload_str, TestOutcome, TestResult,
@@ -42,14 +41,21 @@ fn pc_watch_path() -> Option<&'static PathBuf> {
#[expect(clippy::too_many_arguments)]
fn run_test(
path: &Path, source: &str, meta: &TestMeta, engine: &Engine, harness: &HarnessSources,
harness_cache: &Arc<RwLock<HarnessPrefixCache>>,
harness_module_cache: &Arc<RwLock<HarnessModuleCache>>, no_skip: bool, no_regalloc: bool,
harness_cache: &Arc<RwLock<HarnessPrefixCache>>, harness_module_cache: &Arc<RwLock<HarnessModuleCache>>,
no_skip: bool, no_regalloc: bool,
) -> TestResult {
let start = std::time::Instant::now();
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
run_test_inner(
path, source, meta, engine, harness, harness_cache, harness_module_cache, no_skip,
path,
source,
meta,
engine,
harness,
harness_cache,
harness_module_cache,
no_skip,
no_regalloc,
)
}));
@@ -111,8 +117,8 @@ impl oxide_emit::module::ModuleSourceLoader for Test262ModuleLoader {
#[expect(clippy::too_many_arguments)]
fn run_test_inner(
path: &Path, source: &str, meta: &TestMeta, engine: &Engine, harness: &HarnessSources,
harness_cache: &Arc<RwLock<HarnessPrefixCache>>,
harness_module_cache: &Arc<RwLock<HarnessModuleCache>>, no_skip: bool, no_regalloc: bool,
harness_cache: &Arc<RwLock<HarnessPrefixCache>>, harness_module_cache: &Arc<RwLock<HarnessModuleCache>>,
no_skip: bool, no_regalloc: bool,
) -> TestResult {
let start = std::time::Instant::now();
@@ -167,8 +173,7 @@ fn run_test_inner(
} else {
// script 臂两模块方案:前缀模块按 includes 组合缓存(免每测试重解析重编译),
// 测试体模块每测试编译。onlyStrict 测试给测试体补 "use strict" 保持严格性。
let harness_module = match get_harness_module(meta, harness, engine, &compiler, harness_module_cache)
{
let harness_module = match get_harness_module(meta, harness, engine, &compiler, harness_module_cache) {
Ok(m) => m,
Err(e) => {
let dur = start.elapsed().as_millis() as u64;
@@ -203,8 +208,8 @@ fn run_test_inner(
/// 同口径注入(语料含 eval / Function 动态编译面)。任一模块失败即停,不跑后续模块。
/// 完成值取最后一个模块的结果(script 臂即测试体模块)。
fn run_and_judge(
path: &Path, meta: &TestMeta, engine: &Engine, modules: &[Arc<oxide_bytecode::CompiledModule>],
is_async: bool, no_skip: bool, start: &std::time::Instant,
path: &Path, meta: &TestMeta, engine: &Engine, modules: &[Arc<oxide_bytecode::CompiledModule>], is_async: bool,
no_skip: bool, start: &std::time::Instant,
) -> TestResult {
let mut vm = engine.new_vm();
// 监督者注入现场文件路径时开启 VM 的 last-pc 定频写(未注入时零开销)。
@@ -303,8 +308,15 @@ pub(crate) fn process_path(
}
run_test(
path, &source, &meta, engine, harness_sources, harness_cache, harness_module_cache,
no_skip, no_regalloc,
path,
&source,
&meta,
engine,
harness_sources,
harness_cache,
harness_module_cache,
no_skip,
no_regalloc,
)
}