File tree 3 files changed +42
-0
lines changed
tests/run-make/rustdoc-tempdir-removal
3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ doc( test( attr( deny( warnings) ) ) ) ]
2
+
3
+ //! ```
4
+ //! let a = 12;
5
+ //! ```
Original file line number Diff line number Diff line change
1
+ // This test ensures that no temporary folder is "left behind" when doctests fail for any reason.
2
+
3
+ //@ only-linux
4
+
5
+ use std:: path:: Path ;
6
+
7
+ use run_make_support:: { path, rfs, rustdoc} ;
8
+
9
+ fn run_doctest_and_check_tmpdir ( tmp_dir : & Path , doctest : & str , edition : & str ) {
10
+ let output =
11
+ rustdoc ( ) . input ( doctest) . env ( "TMPDIR" , tmp_dir) . arg ( "--test" ) . edition ( edition) . run_fail ( ) ;
12
+
13
+ output. assert_exit_code ( 101 ) . assert_stdout_contains (
14
+ "test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out" ,
15
+ ) ;
16
+
17
+ rfs:: read_dir_entries ( tmp_dir, |entry| {
18
+ panic ! ( "Found an item inside the temporary folder: {entry:?}" ) ;
19
+ } ) ;
20
+ }
21
+
22
+ fn run_doctest_and_check_tmpdir_for_edition ( tmp_dir : & Path , edition : & str ) {
23
+ run_doctest_and_check_tmpdir ( tmp_dir, "compile-error.rs" , edition) ;
24
+ run_doctest_and_check_tmpdir ( tmp_dir, "run-error.rs" , edition) ;
25
+ }
26
+
27
+ fn main ( ) {
28
+ let tmp_dir = path ( "tmp" ) ;
29
+ rfs:: create_dir ( & tmp_dir) ;
30
+
31
+ run_doctest_and_check_tmpdir_for_edition ( & tmp_dir, "2018" ) ;
32
+ // We use the 2024 edition to check that it's also working for merged doctests.
33
+ run_doctest_and_check_tmpdir_for_edition ( & tmp_dir, "2024" ) ;
34
+ }
Original file line number Diff line number Diff line change
1
+ //! ```
2
+ //! panic!();
3
+ //! ```
You can’t perform that action at this time.
0 commit comments