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

polkadot-sdk-docs: Use command_macro! #6624

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docs/sdk/src/reference_docs/chain_spec_runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ repository.workspace = true
edition.workspace = true
publish = false

[dependencies.command-macros]
version = "0.2.9"
features = ["nightly"]

[dependencies]
docify = { workspace = true }
codec = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![feature(proc_macro_hygiene)]
extern crate command_macros;
use command_macros::command;
use serde_json::{json, Value};
use std::{process::Command, str};

Expand All @@ -8,27 +11,19 @@ const CHAIN_SPEC_BUILDER_PATH: &str = "../../../../../target/release/chain-spec-

fn get_chain_spec_builder_path() -> &'static str {
// dev-dependencies do not build binary. So let's do the naive work-around here:
let _ = std::process::Command::new("cargo")
.arg("build")
.arg("--release")
.arg("-p")
.arg("staging-chain-spec-builder")
.arg("--bin")
.arg("chain-spec-builder")
.status()
.expect("Failed to execute command");
let _ = command!(
cargo build --release -p staging-chain-spec-builder --bin chain-spec-builder
).status().expect("Failed to execute command");
CHAIN_SPEC_BUILDER_PATH
}

#[test]
#[docify::export]
fn list_presets() {
let output = Command::new(get_chain_spec_builder_path())
.arg("list-presets")
.arg("-r")
.arg(WASM_FILE_PATH)
.output()
.expect("Failed to execute command");
let path = get_chain_spec_builder_path();
let output = command!(
(path) list_presets -r (WASM_FILE_PATH)
).output().expect("Failed to execute command");

let output: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();

Expand All @@ -47,15 +42,10 @@ fn list_presets() {
#[test]
#[docify::export]
fn get_preset() {
let output = Command::new(get_chain_spec_builder_path())
.arg("display-preset")
.arg("-r")
.arg(WASM_FILE_PATH)
.arg("-p")
.arg("preset_2")
.output()
.expect("Failed to execute command");

let path = get_chain_spec_builder_path();
let output = command!(
(path) display-preset -r (WASM_FILE_PATH) -p preset-2
).output().expect("Failed to execute command");
let output: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();

//note: copy of chain_spec_guide_runtime::preset_2
Expand All @@ -78,6 +68,7 @@ fn get_preset() {
#[test]
#[docify::export]
fn generate_chain_spec() {
let path = get_chain_spec_builder_path();
let output = Command::new(get_chain_spec_builder_path())
.arg("-c")
.arg("/dev/stdout")
Expand Down Expand Up @@ -131,20 +122,10 @@ fn generate_chain_spec() {
#[test]
#[docify::export]
fn generate_para_chain_spec() {
let output = Command::new(get_chain_spec_builder_path())
.arg("-c")
.arg("/dev/stdout")
.arg("create")
.arg("-c")
.arg("polkadot")
.arg("-p")
.arg("1000")
.arg("-r")
.arg(WASM_FILE_PATH)
.arg("named-preset")
.arg("preset_2")
.output()
.expect("Failed to execute command");
let path = get_chain_spec_builder_path();
let output = command!(
(path) -c /dev/stdout create -c polkadot -p 1000 -r (WASM_FILE_PATH) named-preset preset2
).output().expect("Failed to execute command");

let mut output: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();

Expand Down
Loading