File tree 5 files changed +62
-1
lines changed
5 files changed +62
-1
lines changed Original file line number Diff line number Diff line change @@ -463,7 +463,9 @@ fn run_test(
463
463
// Run the code!
464
464
let mut cmd;
465
465
466
+ let output_file = make_maybe_absolute_path ( output_file) ;
466
467
if let Some ( tool) = runtool {
468
+ let tool = make_maybe_absolute_path ( tool. into ( ) ) ;
467
469
cmd = Command :: new ( tool) ;
468
470
cmd. args ( runtool_args) ;
469
471
cmd. arg ( output_file) ;
@@ -497,6 +499,20 @@ fn run_test(
497
499
Ok ( ( ) )
498
500
}
499
501
502
+ /// Converts a path intended to use as a command to absolute if it is
503
+ /// relative, and not a single component.
504
+ ///
505
+ /// This is needed to deal with relative paths interacting with
506
+ /// `Command::current_dir` in a platform-specific way.
507
+ fn make_maybe_absolute_path ( path : PathBuf ) -> PathBuf {
508
+ if path. components ( ) . count ( ) == 1 {
509
+ // Look up process via PATH.
510
+ path
511
+ } else {
512
+ std:: env:: current_dir ( ) . map ( |c| c. join ( & path) ) . unwrap_or_else ( |_| path)
513
+ }
514
+ }
515
+
500
516
/// Transforms a test into code that can be compiled into a Rust binary, and returns the number of
501
517
/// lines before the test code begins as well as if the output stream supports colors or not.
502
518
pub ( crate ) fn make_test (
Original file line number Diff line number Diff line change @@ -3,7 +3,9 @@ include ../tools.mk
3
3
4
4
# Check that valid binaries are persisted by running them, regardless of whether the --run or --no-run option is used.
5
5
6
- all : run no_run
6
+ MY_SRC_DIR := ${CURDIR}
7
+
8
+ all : run no_run test_run_directory
7
9
8
10
run :
9
11
mkdir -p $(TMPDIR ) /doctests
@@ -20,3 +22,12 @@ no_run:
20
22
$(TMPDIR ) /doctests/t_rs_2_0/rust_out
21
23
$(TMPDIR ) /doctests/t_rs_8_0/rust_out
22
24
rm -rf $(TMPDIR ) /doctests
25
+
26
+ # Behavior with --test-run-directory with relative paths.
27
+ test_run_directory :
28
+ mkdir -p $(TMPDIR ) /doctests
29
+ mkdir -p $(TMPDIR ) /rundir
30
+ $(RUSTC ) --crate-type rlib t.rs
31
+ ( cd $( TMPDIR) ; \
32
+ $(RUSTDOC ) -Zunstable-options --test --persist-doctests doctests --test-run-directory rundir --extern t=libt.rlib $(MY_SRC_DIR ) /t.rs )
33
+ rm -rf $(TMPDIR ) /doctests $(TMPDIR ) /rundir
Original file line number Diff line number Diff line change
1
+ # ignore-cross-compile
2
+ include ../tools.mk
3
+
4
+ # Tests behavior of rustdoc --runtool
5
+
6
+ MY_SRC_DIR := ${CURDIR}
7
+
8
+ all : with_test_run_directory
9
+
10
+ # Behavior with --runtool with relative paths and --test-run-directory.
11
+ with_test_run_directory :
12
+ mkdir -p $(TMPDIR ) /rundir
13
+ mkdir -p $(TMPDIR ) /runtool
14
+ $(RUSTC ) --crate-type rlib t.rs
15
+ $(RUSTC ) runtool.rs -o $(TMPDIR ) /runtool/runtool
16
+ ( cd $( TMPDIR) ; \
17
+ $(RUSTDOC ) -Zunstable-options --test --test-run-directory rundir \
18
+ --runtool runtool/runtool --extern t=libt.rlib $(MY_SRC_DIR ) /t.rs \
19
+ )
20
+ rm -rf $(TMPDIR ) /rundir $(TMPDIR ) /runtool
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ eprintln ! ( "{:?}" , std:: env:: args( ) . collect:: <Vec <_>>( ) ) ;
3
+ }
Original file line number Diff line number Diff line change
1
+ /// Fungle the foople.
2
+ /// ```
3
+ /// t::foople();
4
+ /// ```
5
+ pub fn foople ( ) { }
6
+
7
+ /// Flomble the florp
8
+ /// ```
9
+ /// t::florp();
10
+ /// ```
11
+ pub fn florp ( ) { }
You can’t perform that action at this time.
0 commit comments