From 38e599bac21f463315a652f3ddc972b20c912144 Mon Sep 17 00:00:00 2001 From: pjh456 <147148383@qq.com> Date: Sun, 11 Oct 2026 12:07:58 +0000 Subject: [PATCH] =?UTF-8?q?style:=20=E8=87=AA=E5=8A=A8=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/oxide_test262/src/harness.rs | 4 +-- crates/oxide_test262/src/runner.rs | 38 +++++++++++++++++++---------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/crates/oxide_test262/src/harness.rs b/crates/oxide_test262/src/harness.rs index 6a85a351..57320502 100644 --- a/crates/oxide_test262/src/harness.rs +++ b/crates/oxide_test262/src/harness.rs @@ -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 { +fn build_harness_source(meta: &TestMeta, harness: &HarnessSources, demote: bool) -> Result { let mut source = String::new(); // onlyStrict 测试在严格模式下运行:指令必须位于脚本最前(harness 之前)。 if meta.flags.iter().any(|f| f == "onlyStrict") { diff --git a/crates/oxide_test262/src/runner.rs b/crates/oxide_test262/src/runner.rs index 797c08d3..fa6731d7 100644 --- a/crates/oxide_test262/src/runner.rs +++ b/crates/oxide_test262/src/runner.rs @@ -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>, - harness_module_cache: &Arc>, no_skip: bool, no_regalloc: bool, + harness_cache: &Arc>, harness_module_cache: &Arc>, + 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>, - harness_module_cache: &Arc>, no_skip: bool, no_regalloc: bool, + harness_cache: &Arc>, harness_module_cache: &Arc>, + 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], - is_async: bool, no_skip: bool, start: &std::time::Instant, + path: &Path, meta: &TestMeta, engine: &Engine, modules: &[Arc], 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, ) }