From 013737cb14f0be47f48c5e19e1128ae1ca600b99 Mon Sep 17 00:00:00 2001 From: Pierre Le Fevre Date: Sat, 28 Mar 2026 08:02:53 +0100 Subject: [PATCH] Review fixes: remove redundant constant, fix UTF-8 boundary panic - Remove duplicate TEST_TIMEOUT_INSTRUCTIONS constant (identical to INSTRUCTION_LIMIT), use INSTRUCTION_LIMIT everywhere - Fix potential panic when truncating failure messages containing multi-byte UTF-8 characters by using floor_char_boundary Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/browser/tests/wpt.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/browser/tests/wpt.rs b/crates/browser/tests/wpt.rs index 0386d85..97b3307 100644 --- a/crates/browser/tests/wpt.rs +++ b/crates/browser/tests/wpt.rs @@ -17,10 +17,6 @@ const WORKSPACE_ROOT: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../"); /// Maximum instructions per test (prevents infinite loops). const INSTRUCTION_LIMIT: u64 = 2_000_000; -/// Timeout for individual test files (in instruction count). -/// Tests exceeding this are marked as timeout. -const TEST_TIMEOUT_INSTRUCTIONS: u64 = 2_000_000; - /// Minimal testharness.js shim that implements the WPT test API. /// /// This provides `test()`, `async_test()`, `promise_test()`, `assert_*()`, @@ -513,7 +509,7 @@ fn run_test_file_inner(html: &str) -> TestFileResult { vm.attach_document(doc); // Set instruction limit. - vm.set_instruction_limit(TEST_TIMEOUT_INSTRUCTIONS); + vm.set_instruction_limit(INSTRUCTION_LIMIT); // Execute testharness.js preamble. let preamble_ast = match we_js::parser::Parser::parse(TESTHARNESS_PREAMBLE) { @@ -814,7 +810,8 @@ fn wpt_dom_tests_inner() { break; } let short_msg = if msg.len() > 100 { - format!("{}...", &msg[..100]) + let end = msg.floor_char_boundary(100); + format!("{}...", &msg[..end]) } else { msg.clone() }; -- 2.51.2