Skip to content

Commit 1fd0e9d

Browse files
committed
Move integration tests to cli/tests.
These tests used `assert_cmd::carg::cargo_bin`, which is deprecated. It is meant to be replaced with the macro `assert_cmd::cargo_bin!`, which required tests to be moved to the `cli` crate. If tests hadn't been moved, that macro would fail to find the binary, as the `CARGO_BIN_EXE_*` environment variable with the absolute path to a binary target’s executable would not have been set. Moving the tests causes it to be set, and the macro then works. See https://doc.rust-lang.org/beta/cargo/reference/environment-variables.html
1 parent 6b902c6 commit 1fd0e9d

26 files changed

+23
-23
lines changed

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,11 @@ sp-storage = { workspace = true }
3030
try-runtime-core = { workspace = true }
3131

3232
frame-support = { workspace = true }
33+
34+
[dev-dependencies]
35+
assert_cmd = { workspace = true }
36+
# Only needed in tests
37+
frame-remote-externalities = { workspace = true }
38+
regex = { workspace = true }
39+
substrate-cli-test-utils = { workspace = true, features = ["try-runtime"] }
40+
tempfile = { workspace = true }
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::{
2222
time::Duration,
2323
};
2424

25-
use assert_cmd::cargo::cargo_bin;
25+
use assert_cmd::cargo_bin;
2626
use frame_remote_externalities::{Builder, Mode, OfflineConfig, SnapshotConfig};
2727
use sp_runtime::{
2828
generic::{Block, Header},
@@ -70,7 +70,7 @@ async fn create_snapshot_works() {
7070
snap_file: &PathBuf,
7171
at: sp_core::H256,
7272
) -> tokio::process::Child {
73-
Command::new(cargo_bin("try-runtime"))
73+
Command::new(cargo_bin!("try-runtime"))
7474
.stdout(std::process::Stdio::piped())
7575
.stderr(std::process::Stdio::piped())
7676
.arg("--runtime=existing")
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
use std::time::Duration;
2121

22-
use assert_cmd::cargo::cargo_bin;
22+
use assert_cmd::cargo_bin;
2323
use regex::Regex;
2424
use substrate_cli_test_utils as common;
2525
use tokio::process::Command;
@@ -53,7 +53,7 @@ async fn execute_block_works() {
5353
let ws_url = format!("ws://localhost:{}", port);
5454

5555
fn execute_block(ws_url: &str, at: sp_core::H256) -> tokio::process::Child {
56-
Command::new(cargo_bin("try-runtime"))
56+
Command::new(cargo_bin!("try-runtime"))
5757
.stdout(std::process::Stdio::piped())
5858
.stderr(std::process::Stdio::piped())
5959
.arg("--runtime=existing")
@@ -95,7 +95,7 @@ async fn execute_block_works() {
9595
let ws_url = format!("ws://localhost:{}", port);
9696

9797
fn execute_block(ws_url: &str) -> tokio::process::Child {
98-
Command::new(cargo_bin("try-runtime"))
98+
Command::new(cargo_bin!("try-runtime"))
9999
.stdout(std::process::Stdio::piped())
100100
.stderr(std::process::Stdio::piped())
101101
.arg("--runtime=existing")
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
use std::time::Duration;
2121

22-
use assert_cmd::cargo::cargo_bin;
22+
use assert_cmd::cargo_bin;
2323
use regex::Regex;
2424
use substrate_cli_test_utils as common;
2525
use tokio::process::Command;
@@ -50,7 +50,7 @@ async fn follow_chain_works() {
5050

5151
common::run_with_timeout(Duration::from_secs(60), async move {
5252
fn start_follow(ws_url: &str) -> tokio::process::Child {
53-
Command::new(cargo_bin("try-runtime"))
53+
Command::new(cargo_bin!("try-runtime"))
5454
.stdout(std::process::Stdio::piped())
5555
.stderr(std::process::Stdio::piped())
5656
.arg("--runtime=existing")
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
mod on_runtime_upgrade {
44
use std::{path::PathBuf, time::Duration};
55

6-
use assert_cmd::cargo::cargo_bin;
6+
use assert_cmd::cargo_bin;
77
use substrate_cli_test_utils as common;
88
use tokio::process::Command;
99

@@ -53,7 +53,7 @@ mod on_runtime_upgrade {
5353
}
5454

5555
fn on_runtime_upgrade(config: &TestConfig) -> tokio::process::Child {
56-
let path = cargo_bin("try-runtime");
56+
let path = cargo_bin!("try-runtime");
5757
assert!(
5858
path.exists(),
5959
"try-runtime binary not found at path: {}",
File renamed without changes.

core/tests/runtimes/people_rococo_runtime_different_spec_name.compact.compressed.wasm renamed to cli/tests/runtimes/people_rococo_runtime_different_spec_name.compact.compressed.wasm

File renamed without changes.

core/tests/runtimes/people_rococo_runtime_mbm_double_ok_300b.compact.compressed.wasm renamed to cli/tests/runtimes/people_rococo_runtime_mbm_double_ok_300b.compact.compressed.wasm

File renamed without changes.

core/tests/runtimes/people_rococo_runtime_mbm_duplicates_ok_80b.compact.compressed.wasm renamed to cli/tests/runtimes/people_rococo_runtime_mbm_duplicates_ok_80b.compact.compressed.wasm

File renamed without changes.

0 commit comments

Comments
 (0)