Skip to content

Commit 97d0cf1

Browse files
authored
Allow Targets in Test Cases (#229)
* Add an optional `targets` field to cases. This PR adds an optional `targets` field to cases which takes presence over that same field in the `Metadata`. The hope from this is to allow us to limit specific tests so that they only run on specific platforms only. * Update the resolc tests submodule * Update the default resolc version to use * Update the default heap-size and stack-size in the cli * Update the report processor
1 parent 3c9f845 commit 97d0cf1

File tree

8 files changed

+66
-15
lines changed

8 files changed

+66
-15
lines changed

.github/actions/run-differential-tests/action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ inputs:
2929
default: true
3030
type: boolean
3131
# Test Execution Arguments
32+
# TODO: We need a better way for people to pass arguments to retester. This way is not very good
33+
# because we need to add support for each argument separately and support defaults and all of that
34+
# perhaps having people pass in a JSON String of the arguments is the better long term solution
35+
# for this.
3236
platform:
3337
description: "The identifier of the platform to run the tests on (e.g., geth-evm-solc, revive-dev-node-revm-solc)"
3438
required: true
@@ -121,10 +125,12 @@ runs:
121125
--eth-rpc.path ${{ inputs['polkadot-sdk-path'] }}/target/release/eth-rpc \
122126
--polkadot-omni-node.path ${{ inputs['polkadot-sdk-path'] }}/target/release/polkadot-omni-node \
123127
--resolc.path ./resolc \
128+
--resolc.heap-size 128000 \
129+
--resolc.stack-size 128000 \
124130
"${OMNI_ARGS[@]}" || true
125131
- name: Generate the expectation file
126132
shell: bash
127-
run: report-processor generate-expectations-file --report-path ./workdir/report.json --output-path ./workdir/expectations.json --remove-prefix ./revive-differential-tests/resolc-compiler-tests
133+
run: report-processor generate-expectations-file --report-path ./workdir/report.json --output-path ./workdir/expectations.json --remove-prefix ./revive-differential-tests/resolc-compiler-tests --include-status failed
128134
- name: Upload the Report to the CI
129135
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
130136
with:

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/config/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ pub struct ResolcConfiguration {
806806
/// If unspecified, the revive compiler default is used
807807
#[clap(id = "resolc.heap-size", long = "resolc.heap-size")]
808808
pub heap_size: Option<u32>,
809+
809810
/// Specifies the PVM stack size in bytes.
810811
///
811812
/// If unspecified, the revive compiler default is used

crates/core/src/helpers/test.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,24 @@ impl<'a> TestDefinition<'a> {
223223

224224
/// Checks if the platforms all support the desired targets in the metadata file.
225225
fn check_target_compatibility(&self) -> TestCheckFunctionResult {
226+
// The case targets takes presence over the metadata targets.
227+
let Some(targets) = self
228+
.case
229+
.targets
230+
.as_ref()
231+
.or(self.metadata.targets.as_ref())
232+
else {
233+
return Ok(());
234+
};
235+
226236
let mut error_map = indexmap! {
227-
"test_desired_targets" => json!(self.metadata.targets.as_ref()),
237+
"test_desired_targets" => json!(targets),
228238
};
239+
229240
let mut is_allowed = true;
230241
for (_, platform_information) in self.platforms.iter() {
231-
let is_allowed_for_platform = match self.metadata.targets.as_ref() {
232-
None => true,
233-
Some(required_vm_identifiers) => {
234-
required_vm_identifiers.contains(&platform_information.platform.vm_identifier())
235-
}
236-
};
242+
let is_allowed_for_platform =
243+
targets.contains(&platform_information.platform.vm_identifier());
237244
is_allowed &= is_allowed_for_platform;
238245
error_map.insert(
239246
platform_information.platform.platform_identifier().into(),

crates/format/src/case.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
use alloy::primitives::Address;
1+
use alloy::primitives::{Address, map::HashSet};
22
use schemars::JsonSchema;
33
use serde::{Deserialize, Serialize};
44

55
use revive_dt_common::{
66
macros::define_wrapper_type,
7-
types::{Mode, ParsedMode},
7+
types::{Mode, ParsedMode, VmIdentifier},
88
};
99

1010
use crate::steps::*;
1111

1212
#[derive(Debug, Default, Serialize, Deserialize, Clone, Eq, PartialEq, JsonSchema)]
1313
pub struct Case {
14+
/// An optional vector of targets that this Metadata file's cases can be executed on. As an
15+
/// example, if we wish for the metadata file's cases to only be run on PolkaVM then we'd
16+
/// specify a target of "PolkaVM" in here.
17+
#[serde(skip_serializing_if = "Option::is_none")]
18+
pub targets: Option<HashSet<VmIdentifier>>,
19+
1420
/// An optional name of the test case.
1521
#[serde(skip_serializing_if = "Option::is_none")]
1622
pub name: Option<String>,

crates/format/src/metadata.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::{
88
str::FromStr,
99
};
1010

11+
use alloy::primitives::map::HashSet;
1112
use schemars::JsonSchema;
1213
use serde::{Deserialize, Serialize};
1314

@@ -83,7 +84,7 @@ pub struct Metadata {
8384
/// example, if we wish for the metadata file's cases to only be run on PolkaVM then we'd
8485
/// specify a target of "PolkaVM" in here.
8586
#[serde(skip_serializing_if = "Option::is_none")]
86-
pub targets: Option<Vec<VmIdentifier>>,
87+
pub targets: Option<HashSet<VmIdentifier>>,
8788

8889
/// A vector of the test cases and workloads contained within the metadata file. This is their
8990
/// primary description.

crates/report-processor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ revive-dt-common = { workspace = true }
1818

1919
anyhow = { workspace = true }
2020
clap = { workspace = true }
21+
strum = { workspace = true }
2122
serde = { workspace = true }
2223
serde_json = { workspace = true }
2324

crates/report-processor/src/main.rs

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{
22
borrow::Cow,
3-
collections::{BTreeMap, BTreeSet},
3+
collections::{BTreeMap, BTreeSet, HashSet},
44
fmt::Display,
55
fs::{File, OpenOptions},
66
ops::{Deref, DerefMut},
@@ -9,11 +9,12 @@ use std::{
99
};
1010

1111
use anyhow::{Context as _, Error, Result, bail};
12-
use clap::Parser;
12+
use clap::{Parser, ValueEnum};
1313
use serde::{Deserialize, Serialize, de::DeserializeOwned};
1414

1515
use revive_dt_common::types::{Mode, ParsedTestSpecifier};
1616
use revive_dt_report::{Report, TestCaseStatus};
17+
use strum::EnumString;
1718

1819
fn main() -> Result<()> {
1920
let cli = Cli::try_parse().context("Failed to parse the CLI arguments")?;
@@ -23,11 +24,14 @@ fn main() -> Result<()> {
2324
report_path,
2425
output_path: output_file,
2526
remove_prefix,
27+
include_status,
2628
} => {
2729
let remove_prefix = remove_prefix
2830
.into_iter()
2931
.map(|path| path.canonicalize().context("Failed to canonicalize path"))
3032
.collect::<Result<Vec<_>>>()?;
33+
let include_status =
34+
include_status.map(|value| value.into_iter().collect::<HashSet<_>>());
3135

3236
let expectations = report_path
3337
.execution_information
@@ -73,7 +77,12 @@ fn main() -> Result<()> {
7377
Status::from(status),
7478
)
7579
})
76-
.filter(|(_, status)| *status == Status::Failed)
80+
.filter(|(_, status)| {
81+
include_status
82+
.as_ref()
83+
.map(|allowed_status| allowed_status.contains(status))
84+
.unwrap_or(true)
85+
})
7786
.collect::<Expectations>();
7887

7988
let output_file = OpenOptions::new()
@@ -143,6 +152,11 @@ pub enum Cli {
143152
/// Prefix paths to remove from the paths in the final expectations file.
144153
#[clap(long)]
145154
remove_prefix: Vec<PathBuf>,
155+
156+
/// Controls which test case statuses are included in the generated expectations file. If
157+
/// nothing is specified then it will include all of the test case status.
158+
#[clap(long)]
159+
include_status: Option<Vec<Status>>,
146160
},
147161

148162
/// Compares two expectation files to ensure that they match each other.
@@ -157,7 +171,21 @@ pub enum Cli {
157171
},
158172
}
159173

160-
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
174+
#[derive(
175+
Clone,
176+
Copy,
177+
Debug,
178+
PartialEq,
179+
Eq,
180+
PartialOrd,
181+
Ord,
182+
Hash,
183+
Serialize,
184+
Deserialize,
185+
ValueEnum,
186+
EnumString,
187+
)]
188+
#[strum(serialize_all = "kebab-case")]
161189
pub enum Status {
162190
Succeeded,
163191
Failed,

0 commit comments

Comments
 (0)