Skip to content

Commit a1a5e68

Browse files
committed
Add test for doctest runtool
1 parent d93f678 commit a1a5e68

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

Diff for: tests/rustdoc/doctest/auxiliary/doctest-runtool.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// For some reason on Windows, the PATH to the libstd dylib doesn't seem to
2+
// carry over to running the runtool.
3+
//@ no-prefer-dynamic
4+
5+
use std::path::Path;
6+
use std::process::Command;
7+
8+
fn main() {
9+
let args: Vec<_> = std::env::args().collect();
10+
eprintln!("{args:#?}");
11+
assert_eq!(args.len(), 4);
12+
assert_eq!(args[1], "arg1");
13+
assert_eq!(args[2], "arg2 with space");
14+
let path = Path::new(&args[3]);
15+
let output = Command::new(path).output().unwrap();
16+
// Should fail without env var.
17+
assert!(!output.status.success());
18+
let output = Command::new(path).env("DOCTEST_RUNTOOL_CHECK", "xyz").output().unwrap();
19+
// Should pass with env var.
20+
assert!(output.status.success());
21+
}

Diff for: tests/rustdoc/doctest/doctest-runtool.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Tests that the --runtool argument works.
2+
3+
//@ ignore-cross-compile
4+
//@ aux-bin: doctest-runtool.rs
5+
//@ compile-flags: --test
6+
//@ compile-flags: --runtool=auxiliary/bin/doctest-runtool
7+
//@ compile-flags: --runtool-arg=arg1 --runtool-arg
8+
//@ compile-flags: 'arg2 with space'
9+
//@ compile-flags: -Zunstable-options
10+
11+
/// ```
12+
/// assert_eq!(std::env::var("DOCTEST_RUNTOOL_CHECK"), Ok("xyz".to_string()));
13+
/// ```
14+
pub fn main() {}

0 commit comments

Comments
 (0)