Skip to content

Commit

Permalink
chore(coverage): ignore v8 failed cases from runtime.snap (#6780)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Oct 22, 2024
1 parent b711ee1 commit ffa3945
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 1,530 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion tasks/coverage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ encoding_rs = { workspace = true }
encoding_rs_io = { workspace = true }
futures = { workspace = true }
lazy_static = { workspace = true }
phf = { workspace = true, features = ["macros"] }
pico-args = { workspace = true }
rayon = { workspace = true }
regex = { workspace = true }
Expand Down
1,508 changes: 34 additions & 1,474 deletions tasks/coverage/snapshots/runtime.snap

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tasks/coverage/src/runtime/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v8_test262.status
101 changes: 47 additions & 54 deletions tasks/coverage/src/runtime/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
mod test262_status;

use std::{
path::{Path, PathBuf},
time::Duration,
Expand All @@ -13,7 +15,6 @@ use oxc::{
transformer::{TransformOptions, Transformer},
};
use oxc_tasks_common::agent;
use phf::{phf_set, Set};
use serde_json::json;

use crate::{
Expand All @@ -22,54 +23,51 @@ use crate::{
workspace_root,
};

static SKIP_EVALUATING_FEATURES: Set<&'static str> = phf_set! {
// Node's version of V8 doesn't implement these
"hashbang",
"legacy-regexp",
"regexp-duplicate-named-groups",
"symbols-as-weakmap-keys",
"tail-call-optimization",

// We don't care about API-related things
"ArrayBuffer",
"change-array-by-copy",
"DataView",
"resizable-arraybuffer",
"ShadowRealm",
"cross-realm",
"SharedArrayBuffer",
"String.prototype.toWellFormed",
"Symbol.match",
"Symbol.replace",
"Symbol.unscopables",
"Temporal",
"TypedArray",

// Added in oxc
"Array.fromAsync",
"IsHTMLDDA",
"iterator-helpers",
"set-methods",
"array-grouping",

// stage 2
"Intl.DurationFormat"
};

static SKIP_EVALUATING_THESE_INCLUDES: Set<&'static str> = phf_set! {
use test262_status::get_v8_test262_failure_paths;

static SKIP_EVALUATING_FEATURES: &[&str] = &[
// Node's version of V8 doesn't implement these
"hashbang",
"legacy-regexp",
"regexp-duplicate-named-groups",
"symbols-as-weakmap-keys",
"tail-call-optimization",
// We don't care about API-related things
"ArrayBuffer",
"change-array-by-copy",
"DataView",
"resizable-arraybuffer",
"ShadowRealm",
"cross-realm",
"SharedArrayBuffer",
"String.prototype.toWellFormed",
"Symbol.match",
"Symbol.replace",
"Symbol.unscopables",
"Temporal",
"TypedArray",
// Added in oxc
"Array.fromAsync",
"IsHTMLDDA",
"iterator-helpers",
"set-methods",
"array-grouping",
// stage 2
"Intl.DurationFormat",
];

static SKIP_EVALUATING_THESE_INCLUDES: &[&str] = &[
// We don't preserve "toString()" on functions
"nativeFunctionMatcher.js",
};
];

static SKIP_TEST_CASES: Set<&'static str> = phf_set! {
static SKIP_TEST_CASES: &[&str] = &[
// For some unknown reason these tests are unstable, so we'll skip them for now.
"language/identifiers/start-unicode",
// Properly misconfigured test setup for `eval`, but can't figure out where
"annexB/language/eval-code",
"language/eval-code"
};

const FIXTURES_PATH: &str = "test262/test";
"language/eval-code",
];

pub struct Test262RuntimeCase {
base: Test262Case,
Expand All @@ -78,7 +76,7 @@ pub struct Test262RuntimeCase {

impl Case for Test262RuntimeCase {
fn new(path: PathBuf, code: String) -> Self {
Self { base: Test262Case::new(path, code), test_root: workspace_root().join(FIXTURES_PATH) }
Self { base: Test262Case::new(path, code), test_root: workspace_root() }
}

fn code(&self) -> &str {
Expand All @@ -95,23 +93,18 @@ impl Case for Test262RuntimeCase {

fn skip_test_case(&self) -> bool {
let base_path = self.base.path().to_string_lossy();
let includes = &self.base.meta().includes;
let features = &self.base.meta().features;
self.base.should_fail()
|| self.base.skip_test_case()
|| base_path.contains("built-ins")
|| base_path.contains("staging")
|| base_path.contains("intl402")
|| self
.base
.meta()
.includes
.iter()
.any(|include| SKIP_EVALUATING_THESE_INCLUDES.contains(include))
|| self
.base
.meta()
.features
|| get_v8_test262_failure_paths().iter().any(|test| base_path.contains(test))
|| includes
.iter()
.any(|feature| SKIP_EVALUATING_FEATURES.contains(feature))
.any(|include| SKIP_EVALUATING_THESE_INCLUDES.contains(&include.as_ref()))
|| features.iter().any(|feature| SKIP_EVALUATING_FEATURES.contains(&feature.as_ref()))
|| SKIP_TEST_CASES.iter().any(|path| base_path.contains(path))
|| self.base.code().contains("$262")
|| self.base.code().contains("$DONOTEVALUATE()")
Expand Down
6 changes: 6 additions & 0 deletions tasks/coverage/src/runtime/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ async function runCodeInHarness(options = {}) {
const { code = '', includes = [], importDir = '', isAsync = false, isModule = true, isRaw = false } = options;
const context = {};

if (process.env.DEBUG) {
const { code: c, ...o } = options;
console.log(c);
console.log(o);
}

// See: https://github.com/nodejs/node/issues/36351
const unique = () => '//' + Math.random();

Expand Down
44 changes: 44 additions & 0 deletions tasks/coverage/src/runtime/test262_status.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use std::{fs, sync::OnceLock, time::Duration};

use oxc_tasks_common::agent;

use crate::workspace_root;

/// Generate v8 test262 status file, which is used to skip failed tests
/// see <https://chromium.googlesource.com/v8/v8/+/refs/heads/main/test/test262/test262.status>
///
/// # Panics
pub fn get_v8_test262_failure_paths() -> &'static Vec<String> {
static STATUS: OnceLock<Vec<String>> = OnceLock::new();
STATUS.get_or_init(|| {
let path = workspace_root().join("src/runtime/v8_test262.status");

let lines = if path.exists() {
fs::read_to_string(&path).unwrap().lines().map(ToString::to_string).collect::<Vec<_>>()
} else {
let res = agent()
.get("http://raw.githubusercontent.com/v8/v8/main/test/test262/test262.status")
.timeout(Duration::from_secs(10))
.call()
.unwrap()
.into_string()
.unwrap();
let mut tests = vec![];
regex::Regex::new(r"'(.+)': \[(FAIL|SKIP)\]").unwrap().captures_iter(&res).for_each(
|caps| {
if let Some(name) = caps.get(1).map(|f| f.as_str()) {
if !name.eq("*") {
tests.push(name.to_string());
}
}
},
);
tests.sort_unstable();
tests.dedup();
fs::write(path, tests.join("\n")).unwrap();
tests
};

lines
})
}

0 comments on commit ffa3945

Please sign in to comment.