mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-12 17:01:06 +00:00
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.
This commit is contained in:
@@ -223,17 +223,24 @@ impl<'a> TestDefinition<'a> {
|
||||
|
||||
/// Checks if the platforms all support the desired targets in the metadata file.
|
||||
fn check_target_compatibility(&self) -> TestCheckFunctionResult {
|
||||
let mut error_map = indexmap! {
|
||||
"test_desired_targets" => json!(self.metadata.targets.as_ref()),
|
||||
// The case targets takes presence over the metadata targets.
|
||||
let Some(targets) = self
|
||||
.case
|
||||
.targets
|
||||
.as_ref()
|
||||
.or(self.metadata.targets.as_ref())
|
||||
else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
let mut error_map = indexmap! {
|
||||
"test_desired_targets" => json!(targets),
|
||||
};
|
||||
|
||||
let mut is_allowed = true;
|
||||
for (_, platform_information) in self.platforms.iter() {
|
||||
let is_allowed_for_platform = match self.metadata.targets.as_ref() {
|
||||
None => true,
|
||||
Some(required_vm_identifiers) => {
|
||||
required_vm_identifiers.contains(&platform_information.platform.vm_identifier())
|
||||
}
|
||||
};
|
||||
let is_allowed_for_platform =
|
||||
targets.contains(&platform_information.platform.vm_identifier());
|
||||
is_allowed &= is_allowed_for_platform;
|
||||
error_map.insert(
|
||||
platform_information.platform.platform_identifier().into(),
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
use alloy::primitives::Address;
|
||||
use alloy::primitives::{Address, map::HashSet};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use revive_dt_common::{
|
||||
macros::define_wrapper_type,
|
||||
types::{Mode, ParsedMode},
|
||||
types::{Mode, ParsedMode, VmIdentifier},
|
||||
};
|
||||
|
||||
use crate::steps::*;
|
||||
|
||||
#[derive(Debug, Default, Serialize, Deserialize, Clone, Eq, PartialEq, JsonSchema)]
|
||||
pub struct Case {
|
||||
/// An optional vector of targets that this Metadata file's cases can be executed on. As an
|
||||
/// example, if we wish for the metadata file's cases to only be run on PolkaVM then we'd
|
||||
/// specify a target of "PolkaVM" in here.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub targets: Option<HashSet<VmIdentifier>>,
|
||||
|
||||
/// An optional name of the test case.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub name: Option<String>,
|
||||
|
||||
@@ -8,6 +8,7 @@ use std::{
|
||||
str::FromStr,
|
||||
};
|
||||
|
||||
use alloy::primitives::map::HashSet;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -83,7 +84,7 @@ pub struct Metadata {
|
||||
/// example, if we wish for the metadata file's cases to only be run on PolkaVM then we'd
|
||||
/// specify a target of "PolkaVM" in here.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub targets: Option<Vec<VmIdentifier>>,
|
||||
pub targets: Option<HashSet<VmIdentifier>>,
|
||||
|
||||
/// A vector of the test cases and workloads contained within the metadata file. This is their
|
||||
/// primary description.
|
||||
|
||||
Reference in New Issue
Block a user