mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 07:47:57 +00:00
54 lines
1.8 KiB
Rust
54 lines
1.8 KiB
Rust
// Copyright 2019-2022 Parity Technologies (UK) Ltd.
|
|
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
|
// see LICENSE for license details.
|
|
#![cfg(test)]
|
|
|
|
//! UI test set uses [`trybuild`](https://docs.rs/trybuild/latest/trybuild/index.html) to
|
|
//! check whether expected valid examples of code compile correctly, and for incorrect ones
|
|
//! errors are helpful and valid (e.g. have correct spans).
|
|
//!
|
|
//!
|
|
//! Use with `TRYBUILD=overwrite` after updating codebase (see `trybuild` docs for more details on that)
|
|
//! to automatically regenerate `stderr` files, but don't forget to check that new files make sense.
|
|
|
|
mod dispatch_errors;
|
|
mod storage;
|
|
mod utils;
|
|
|
|
use crate::utils::MetadataTestRunner;
|
|
|
|
// Each of these tests leads to some rust code being compiled and
|
|
// executed to test that compilation is successful (or errors in the
|
|
// way that we'd expect).
|
|
#[test]
|
|
fn ui_tests() {
|
|
let mut m = MetadataTestRunner::default();
|
|
let t = trybuild::TestCases::new();
|
|
|
|
// Check that storage maps with no keys are handled properly.
|
|
t.pass(&m.path_to_ui_test_for_metadata(
|
|
"storage_map_no_keys",
|
|
storage::metadata_storage_map_no_keys(),
|
|
));
|
|
|
|
// Test that the codegen can handle the different types of DispatchError.
|
|
t.pass(&m.path_to_ui_test_for_metadata(
|
|
"named_field_dispatch_error",
|
|
dispatch_errors::metadata_named_field_dispatch_error(),
|
|
));
|
|
t.pass(&m.path_to_ui_test_for_metadata(
|
|
"legacy_dispatch_error",
|
|
dispatch_errors::metadata_legacy_dispatch_error(),
|
|
));
|
|
t.pass(&m.path_to_ui_test_for_metadata(
|
|
"array_dispatch_error",
|
|
dispatch_errors::metadata_array_dispatch_error(),
|
|
));
|
|
}
|
|
|
|
#[test]
|
|
fn ui_fail() {
|
|
let t = trybuild::TestCases::new();
|
|
t.compile_fail("src/incorrect/*.rs");
|
|
}
|