Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speed up ui tests. #944

Merged
merged 27 commits into from
May 12, 2023
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
02db651
speed up ui tests by reducing number of pallets
tadeohepperle May 2, 2023
7c5e091
Merge branch 'master' into tadeo-hepperle-speed-up-tests
tadeohepperle May 2, 2023
2f4fc25
add small and tiny versions of polkadot metadata
tadeohepperle May 3, 2023
7b0c416
Merge branch 'master' into tadeo-hepperle-speed-up-tests
tadeohepperle May 3, 2023
9414fd8
change drop implementation fix test
tadeohepperle May 3, 2023
8a514ee
rust yml add nextest and merge tests
tadeohepperle May 3, 2023
ed667dc
2
tadeohepperle May 3, 2023
7119c69
3
tadeohepperle May 3, 2023
b7f98ec
4
tadeohepperle May 3, 2023
779f628
5
tadeohepperle May 4, 2023
a466d4d
6
tadeohepperle May 4, 2023
b937398
add script for generating files
tadeohepperle May 4, 2023
2d83019
Upgrade to `syn 2.0` (#875)
ascjones May 3, 2023
5f4610e
Metadata V15: Generate Runtime APIs (#918)
lexnv May 3, 2023
605ed70
add small and tiny versions of polkadot metadata
tadeohepperle May 3, 2023
342030c
add script for generating files
tadeohepperle May 4, 2023
29d7e40
merged
tadeohepperle May 4, 2023
2990f3f
new metadata
tadeohepperle May 4, 2023
7bd4bfd
Runtime APIs; don't ask for validation hash anywhere except new_stati…
jsdw May 4, 2023
9e17507
Subxt Guide (#890)
jsdw May 4, 2023
fcf88b6
merge conflict
tadeohepperle May 4, 2023
b07f015
use new metadata files in book
tadeohepperle May 4, 2023
82a5a21
use mtadata full in docs
tadeohepperle May 5, 2023
0b7616a
Merge branch 'master' into tadeo-hepperle-speed-up-tests
tadeohepperle May 11, 2023
a6f2a17
regenerate polkadot.rs
tadeohepperle May 11, 2023
ae211fb
use small metadata in a couple of places
tadeohepperle May 11, 2023
0076855
Update scripts/artifacts.sh
tadeohepperle May 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
speed up ui tests by reducing number of pallets
  • Loading branch information
tadeohepperle committed May 2, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 02db6518ad074fb53dfa976d6039c60f44397300
Binary file added artifacts/polkadot_metadata_tiny.scale
Binary file not shown.
3 changes: 2 additions & 1 deletion testing/ui-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -23,7 +23,8 @@ use crate::utils::{MetadataTestRunner, PalletMetadataTestRunner};
#[test]
fn ui_tests() {
let mut m = MetadataTestRunner::default();
let mut p = PalletMetadataTestRunner::new();
// specify pallets we want to test the metadata for (None => all pallets, but specifying only Some(..) speeds up test)
let mut p = PalletMetadataTestRunner::new(Some(&["Grandpa", "Claims", "Babe"]));
let t = trybuild::TestCases::new();

t.pass("src/correct/*.rs");
19 changes: 15 additions & 4 deletions testing/ui-tests/src/utils/pallet_metadata_test_runner.rs
Original file line number Diff line number Diff line change
@@ -13,10 +13,12 @@ static METADATA_FILE: &str = "../../artifacts/polkadot_metadata.scale";
pub struct PalletMetadataTestRunner {
metadata: RuntimeMetadataV15,
index: usize,
pallet_names: Option<Vec<String>>,
}

impl PalletMetadataTestRunner {
pub fn new() -> PalletMetadataTestRunner {
/// if pallet_names is Some(..) only the provided pallets will be tested.
pub fn new(pallet_names: Option<&[&str]>) -> PalletMetadataTestRunner {
let mut file =
std::fs::File::open(METADATA_FILE).expect("Cannot open metadata.scale artifact");

@@ -32,19 +34,28 @@ impl PalletMetadataTestRunner {
frame_metadata::RuntimeMetadata::V15(v15) => v15,
_ => panic!("Unsupported metadata version {:?}", meta.1),
};

PalletMetadataTestRunner { metadata, index: 0 }
let pallet_names = pallet_names.map(|v| v.iter().map(|e| e.to_string()).collect());
PalletMetadataTestRunner {
metadata,
index: 0,
pallet_names,
}
}

pub fn path_to_next_ui_test(&mut self) -> Option<String> {
let Some(pallet) = self.metadata.pallets.get(self.index) else {
return None
};
let test_name = &pallet.name;

// Increment test index to avoid overlaps.
let index = self.index;
self.index += 1;
// if a pallet filter is set (pallet_names is Some), return the next pallet if this pallet is not in the filter.
if let Some(name_filter) = self.pallet_names.as_ref() {
if !name_filter.contains(test_name) {
return self.path_to_next_ui_test();
}
}

// Build custom metadata containing only this pallet.
let mut metadata = self.metadata.clone();