From 94f15a5c18bac7736d50d37a0b1467c65ba1bac4 Mon Sep 17 00:00:00 2001 From: Kevin Ness <46825870+nekevss@users.noreply.github.com> Date: Thu, 26 Dec 2024 22:59:03 -0600 Subject: [PATCH] Bump test262 and adjustments to boa_tester for sm harness --- test262_config.toml | 5 +++- tests/tester/src/edition.rs | 4 +++ tests/tester/src/read.rs | 56 +++++++++++++++++++++++++++++-------- 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/test262_config.toml b/test262_config.toml index f3020ef1272..19a2d32345e 100644 --- a/test262_config.toml +++ b/test262_config.toml @@ -1,4 +1,4 @@ -commit = "dad2774b2eab2119cc8390ae65db4a5016de2dfe" +commit = "8296db887368bbffa3379f995a1e628ddbe8421f" [ignored] # Not implemented yet: @@ -35,6 +35,9 @@ features = [ # https://tc39.es/proposal-defer-import-eval "import-defer", + # https://github.com/tc39/proposal-iterator-sequencing + "iterator-sequencing", + # https://github.com/tc39/proposal-json-modules "json-modules", diff --git a/tests/tester/src/edition.rs b/tests/tester/src/edition.rs index 38ca0896665..9fd774c8bf0 100644 --- a/tests/tester/src/edition.rs +++ b/tests/tester/src/edition.rs @@ -45,6 +45,10 @@ static FEATURE_EDITION: phf::Map<&'static str, SpecEdition> = phf::phf_map! { // https://github.com/tc39/proposal-import-assertions/ "import-assertions" => SpecEdition::ESNext, + // Iterator sequencing + // https://github.com/tc39/proposal-iterator-sequencing + "iterator-sequencing" => SpecEdition::ESNext, + // JSON modules // https://github.com/tc39/proposal-json-modules "json-modules" => SpecEdition::ESNext, diff --git a/tests/tester/src/read.rs b/tests/tester/src/read.rs index 1fac7223c2d..8087ecc6ca9 100644 --- a/tests/tester/src/read.rs +++ b/tests/tester/src/read.rs @@ -1,6 +1,7 @@ //! Module to read the list of test suites from disk. use std::{ + collections::HashMap, ffi::OsStr, fs, path::{Path, PathBuf}, @@ -10,7 +11,7 @@ use color_eyre::{ eyre::{OptionExt, WrapErr}, Result, }; -use rustc_hash::FxHashMap; +use rustc_hash::{FxBuildHasher, FxHashMap}; use serde::Deserialize; use crate::{HarnessFile, Ignored}; @@ -92,16 +93,9 @@ pub(super) enum TestFlag { /// Reads the Test262 defined bindings. pub(super) fn read_harness(test262_path: &Path) -> Result { - fn read_harness_file(path: PathBuf) -> Result { - let content = fs::read_to_string(path.as_path()) - .wrap_err_with(|| format!("error reading the harness file `{}`", path.display()))?; - - Ok(HarnessFile { - content: content.into_boxed_str(), - path: path.into_boxed_path(), - }) - } - let mut includes = FxHashMap::default(); + let mut includes: HashMap, HarnessFile, FxBuildHasher> = FxHashMap::default(); + + read_harness_dir(&test262_path.join("harness"), &mut includes)?; for entry in fs::read_dir(test262_path.join("harness")) .wrap_err("error reading the harness directory")? @@ -110,7 +104,11 @@ pub(super) fn read_harness(test262_path: &Path) -> Result { let file_name = entry.file_name(); let file_name = file_name.to_string_lossy(); - if file_name == "assert.js" || file_name == "sta.js" || file_name == "doneprintHandle.js" { + if file_name == "assert.js" + || file_name == "sta.js" + || file_name == "doneprintHandle.js" + || file_name == "sm" + { continue; } @@ -131,6 +129,40 @@ pub(super) fn read_harness(test262_path: &Path) -> Result { }) } +fn read_harness_dir( + directory_name: &Path, + includes: &mut HashMap, HarnessFile, FxBuildHasher>, +) -> Result<()> { + for entry in fs::read_dir(directory_name).wrap_err("error reading the harness directory")? { + let entry = entry?; + let file_name = entry.file_name(); + let file_name = file_name.to_string_lossy().into_owned(); + + if directory_name.join(file_name.clone()).is_dir() { + read_harness_dir(&directory_name.join(file_name), includes)?; + continue; + } + + if file_name == "assert.js" || file_name == "sta.js" || file_name == "doneprintHandle.js" { + continue; + } + + includes.insert(file_name.into_boxed_str(), read_harness_file(entry.path())?); + } + + Ok(()) +} + +fn read_harness_file(path: PathBuf) -> Result { + let content = fs::read_to_string(path.as_path()) + .wrap_err_with(|| format!("error reading the harness file `{}`", path.display()))?; + + Ok(HarnessFile { + content: content.into_boxed_str(), + path: path.into_boxed_path(), + }) +} + /// Reads a test suite in the given path. pub(super) fn read_suite( path: &Path,