Add --derive-for-type to cli (#708)

* Add `--derive-for-type` to cli

* Remove clippy warnings
This commit is contained in:
Francisco Miguel García
2022-11-23 16:25:32 +01:00
committed by GitHub
parent 702e87e58d
commit a80d6cfd30
6 changed files with 41 additions and 21 deletions
+2 -2
View File
@@ -80,7 +80,7 @@ async fn run() {
// Save metadata to a file:
let out_dir = env::var_os("OUT_DIR").unwrap();
let metadata_path = Path::new(&out_dir).join("metadata.scale");
fs::write(&metadata_path, &metadata_bytes.0).expect("Couldn't write metadata output");
fs::write(&metadata_path, metadata_bytes.0).expect("Couldn't write metadata output");
// Write out our expression to generate the runtime API to a file. Ideally, we'd just write this code
// in lib.rs, but we must pass a string literal (and not `concat!(..)`) as an arg to `runtime_metadata_path`,
@@ -101,7 +101,7 @@ async fn run() {
.expect("Path to metadata should be stringifiable")
);
let runtime_path = Path::new(&out_dir).join("runtime.rs");
fs::write(&runtime_path, runtime_api_contents)
fs::write(runtime_path, runtime_api_contents)
.expect("Couldn't write runtime rust output");
let substrate_path =
+4 -4
View File
@@ -28,21 +28,21 @@ fn ui_tests() {
t.pass("src/correct/*.rs");
// Check that storage maps with no keys are handled properly.
t.pass(&m.path_to_ui_test_for_metadata(
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(
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(
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(
t.pass(m.path_to_ui_test_for_metadata(
"array_dispatch_error",
dispatch_errors::metadata_array_dispatch_error(),
));
@@ -52,9 +52,9 @@ impl MetadataTestRunner {
std::fs::create_dir_all(&tmp_dir).expect("could not create tmp ui test dir");
// Write metadata to tmp folder:
std::fs::write(&tmp_metadata_path, &encoded_metadata).unwrap();
std::fs::write(&tmp_metadata_path, encoded_metadata).unwrap();
// Write test file to tmp folder (it'll be moved by trybuild):
std::fs::write(&tmp_rust_path, &rust_file).unwrap();
std::fs::write(&tmp_rust_path, rust_file).unwrap();
tmp_rust_path
}