Skip to content

Commit 780fd83

Browse files
authored
Merge pull request #2886 from ehuss/simplify-runner
Simplify GUI runner
2 parents 5e7b6d7 + d5406c8 commit 780fd83

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

tests/gui/runner.rs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
use serde_json::Value;
88
use std::fs::read_to_string;
9-
use std::path::{Path, PathBuf};
9+
use std::path::Path;
1010
use std::process::{Command, Output};
1111

1212
fn get_available_browser_ui_test_version_inner(global: bool) -> Option<String> {
@@ -75,7 +75,6 @@ fn main() {
7575
}
7676

7777
fn build_books(out_dir: &Path) {
78-
let exe = build_mdbook();
7978
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
8079
let books_dir = root.join("tests/gui/books");
8180
for entry in books_dir.read_dir().unwrap() {
@@ -85,7 +84,7 @@ fn build_books(out_dir: &Path) {
8584
continue;
8685
}
8786
println!("Building `{}`", path.display());
88-
let mut cmd = Command::new(&exe);
87+
let mut cmd = Command::new(env!("CARGO_BIN_EXE_mdbook"));
8988
let output = cmd
9089
.arg("build")
9190
.arg("--dest-dir")
@@ -97,28 +96,6 @@ fn build_books(out_dir: &Path) {
9796
}
9897
}
9998

100-
fn build_mdbook() -> PathBuf {
101-
let mut cmd = Command::new("cargo");
102-
let output = cmd
103-
.arg("build")
104-
.output()
105-
.expect("cargo should be installed");
106-
check_status(&cmd, &output);
107-
let target_dir = detect_target_dir();
108-
target_dir.join("debug/mdbook")
109-
}
110-
111-
fn detect_target_dir() -> PathBuf {
112-
let mut cmd = Command::new("cargo");
113-
let output = cmd
114-
.args(["metadata", "--format-version=1", "--no-deps"])
115-
.output()
116-
.expect("cargo should be installed");
117-
check_status(&cmd, &output);
118-
let v: serde_json::Value = serde_json::from_slice(&output.stdout).expect("invalid json");
119-
PathBuf::from(v["target_directory"].as_str().unwrap())
120-
}
121-
12299
fn check_status(cmd: &Command, output: &Output) {
123100
if !output.status.success() {
124101
eprintln!("error: `{cmd:?}` failed");

0 commit comments

Comments
 (0)