Skip to content

Commit

Permalink
fix: Fix segmentation fault in tests on CPUs with PKU support (denola…
Browse files Browse the repository at this point in the history
…nd#22152)

This is a followup on denoland/deno_core#471.

Fixes denoland#21439.
  • Loading branch information
Digifox03 authored and mmastrac committed Feb 5, 2024
1 parent e53ced0 commit 493b3b6
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 13 deletions.
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ nix.workspace = true

[dev-dependencies]
deno_bench_util.workspace = true
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting", "unsafe_use_unprotected_platform"] }
fastwebsockets = { workspace = true, features = ["upgrade", "unstable-split"] }
flaky_test = "=0.1.0"
http.workspace = true
Expand Down
4 changes: 3 additions & 1 deletion cli/lsp/testing/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ impl TestRun {
test::TestResult::Ignored => summary.ignored += 1,
test::TestResult::Failed(error) => {
summary.failed += 1;
summary.failures.push((description.clone(), error.clone()));
summary
.failures
.push(((&description).into(), error.clone()));
}
test::TestResult::Cancelled => {
summary.failed += 1;
Expand Down
23 changes: 22 additions & 1 deletion cli/tools/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,27 @@ pub struct TestDescription {
pub location: TestLocation,
}

/// May represent a failure of a test or test step.
#[derive(Debug, Clone, PartialEq, Deserialize, Eq, Hash)]
#[serde(rename_all = "camelCase")]
pub struct TestFailureDescription {
pub id: usize,
pub name: String,
pub origin: String,
pub location: TestLocation,
}

impl From<&TestDescription> for TestFailureDescription {
fn from(value: &TestDescription) -> Self {
Self {
id: value.id,
name: value.name.clone(),
origin: value.origin.clone(),
location: value.location.clone(),
}
}
}

#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Debug, Clone, PartialEq, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand Down Expand Up @@ -332,7 +353,7 @@ pub struct TestSummary {
pub ignored_steps: usize,
pub filtered_out: usize,
pub measured: usize,
pub failures: Vec<(TestDescription, TestFailure)>,
pub failures: Vec<(TestFailureDescription, TestFailure)>,
pub uncaught_errors: Vec<(String, Box<JsError>)>,
}

Expand Down
12 changes: 9 additions & 3 deletions cli/tools/test/reporters/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ pub(super) fn format_test_step_ancestry(
result
}

pub fn format_test_for_summary(cwd: &Url, desc: &TestDescription) -> String {
pub fn format_test_for_summary(
cwd: &Url,
desc: &TestFailureDescription,
) -> String {
format!(
"{} {}",
&desc.name,
Expand Down Expand Up @@ -78,7 +81,7 @@ pub(super) fn report_sigint(
let mut formatted_pending = BTreeSet::new();
for id in tests_pending {
if let Some(desc) = tests.get(id) {
formatted_pending.insert(format_test_for_summary(cwd, desc));
formatted_pending.insert(format_test_for_summary(cwd, &desc.into()));
}
if let Some(desc) = test_steps.get(id) {
formatted_pending
Expand Down Expand Up @@ -107,7 +110,10 @@ pub(super) fn report_summary(
#[allow(clippy::type_complexity)] // Type alias doesn't look better here
let mut failures_by_origin: BTreeMap<
String,
(Vec<(&TestDescription, &TestFailure)>, Option<&JsError>),
(
Vec<(&TestFailureDescription, &TestFailure)>,
Option<&JsError>,
),
> = BTreeMap::default();
let mut failure_titles = vec![];
for (description, failure) in &summary.failures {
Expand Down
6 changes: 2 additions & 4 deletions cli/tools/test/reporters/dot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl TestReporter for DotTestReporter {
self
.summary
.failures
.push((description.clone(), failure.clone()));
.push((description.into(), failure.clone()));
}
TestResult::Cancelled => {
self.summary.failed += 1;
Expand Down Expand Up @@ -162,11 +162,9 @@ impl TestReporter for DotTestReporter {
TestStepResult::Failed(failure) => {
self.summary.failed_steps += 1;
self.summary.failures.push((
TestDescription {
TestFailureDescription {
id: desc.id,
name: common::format_test_step_ancestry(desc, tests, test_steps),
ignore: false,
only: false,
origin: desc.origin.clone(),
location: desc.location.clone(),
},
Expand Down
6 changes: 2 additions & 4 deletions cli/tools/test/reporters/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl TestReporter for PrettyTestReporter {
self
.summary
.failures
.push((description.clone(), failure.clone()));
.push((description.into(), failure.clone()));
}
TestResult::Cancelled => {
self.summary.failed += 1;
Expand Down Expand Up @@ -318,11 +318,9 @@ impl TestReporter for PrettyTestReporter {
TestStepResult::Failed(failure) => {
self.summary.failed_steps += 1;
self.summary.failures.push((
TestDescription {
TestFailureDescription {
id: desc.id,
name: common::format_test_step_ancestry(desc, tests, test_steps),
ignore: false,
only: false,
origin: desc.origin.clone(),
location: desc.location.clone(),
},
Expand Down

0 comments on commit 493b3b6

Please sign in to comment.