compiletest::runtest

Struct TestCx

source
struct TestCx<'test> {
    config: &'test Config,
    props: &'test TestProps,
    testpaths: &'test TestPaths,
    revision: Option<&'test str>,
}

Fields§

§config: &'test Config§props: &'test TestProps§testpaths: &'test TestPaths§revision: Option<&'test str>

Implementations§

source§

impl TestCx<'_>

source

pub(super) fn run_assembly_test(&self)

source§

impl TestCx<'_>

source

pub(super) fn run_codegen_test(&self)

source§

impl TestCx<'_>

source

pub(super) fn run_codegen_units_test(&self)

source§

impl<'test> TestCx<'test>

source

fn coverage_dump_path(&self) -> &Path

source

pub(super) fn run_coverage_map_test(&self)

source

pub(super) fn run_coverage_run_test(&self)

source

fn run_doctests_for_coverage( &self, profraw_paths: &mut Vec<PathBuf>, bin_paths: &mut Vec<PathBuf>, )

Run any doctests embedded in this test file, and add any resulting .profraw files and doctest executables to the given vectors.

source

fn run_llvm_tool( &self, name: &str, configure_cmd_fn: impl FnOnce(&mut Command), ) -> ProcRes

source

fn normalize_coverage_output(&self, coverage: &str) -> Result<String, String>

source

fn anonymize_coverage_line_numbers(coverage: &str) -> String

Replace line numbers in coverage reports with the placeholder LL, so that the tests are less sensitive to lines being added/removed.

source

fn sort_coverage_file_sections( coverage_lines: &mut Vec<&str>, ) -> Result<(), String>

Coverage reports can describe multiple source files, separated by blank lines. The order of these files is unpredictable (since it depends on implementation details), so we need to sort the file sections into a consistent order before comparing against a snapshot.

source

fn sort_coverage_subviews(coverage_lines: &mut Vec<&str>) -> Result<(), String>

source§

impl TestCx<'_>

source

pub(super) fn run_crash_test(&self)

source§

impl TestCx<'_>

source§

impl TestCx<'_>

source§

impl TestCx<'_>

source

pub(super) fn run_js_doc_test(&self)

source§

impl TestCx<'_>

source

pub(super) fn run_mir_opt_test(&self)

source

fn check_mir_dump(&self, test_info: MiroptTest)

source

fn diff_mir_files(&self, before: PathBuf, after: PathBuf) -> String

source

fn check_mir_test_timestamp(&self, test_name: &str, output_file: &Path)

source§

impl TestCx<'_>

source

pub(super) fn run_pretty_test(&self)

source§

impl TestCx<'_>

source§

impl TestCx<'_>

source

pub(super) fn run_rustdoc_test(&self)

source§

impl TestCx<'_>

source

pub(super) fn run_rustdoc_json_test(&self)

source§

impl TestCx<'_>

source

pub(super) fn run_ui_test(&self)

source§

impl<'test> TestCx<'test>

source

fn run_revision(&self)

Code executed for each revision in turn (or, if there are no revisions, exactly once, with revision == None).

source

fn pass_mode(&self) -> Option<PassMode>

source

fn should_run(&self, pm: Option<PassMode>) -> WillExecute

source

fn run_if_enabled(&self) -> WillExecute

source

fn should_run_successfully(&self, pm: Option<PassMode>) -> bool

source

fn should_compile_successfully(&self, pm: Option<PassMode>) -> bool

source

fn check_if_test_should_compile( &self, fail_mode: Option<FailMode>, pass_mode: Option<PassMode>, proc_res: &ProcRes, )

source

fn get_output(&self, proc_res: &ProcRes) -> String

source

fn check_correct_failure_status(&self, proc_res: &ProcRes)

source

fn run_command_to_procres(&self, cmd: &mut Command) -> ProcRes

Runs a Command and waits for it to finish, then converts its exit status and output streams into a ProcRes.

The command might have succeeded or failed; it is the caller’s responsibility to check the exit status and take appropriate action.

§Panics

Panics if the command couldn’t be executed at all (e.g. because the executable could not be found).

source

fn print_source(&self, read_from: ReadFrom, pretty_type: &str) -> ProcRes

source

fn compare_source(&self, expected: &str, actual: &str)

source

fn set_revision_flags(&self, cmd: &mut Command)

source

fn typecheck_source(&self, src: String) -> ProcRes

source

fn maybe_add_external_args(&self, cmd: &mut Command, args: &Vec<String>)

source

fn check_all_error_patterns( &self, output_to_check: &str, proc_res: &ProcRes, pm: Option<PassMode>, )

source

fn check_error_patterns( &self, output_to_check: &str, missing_patterns: &mut Vec<String>, )

source

fn check_regex_error_patterns( &self, output_to_check: &str, proc_res: &ProcRes, missing_patterns: &mut Vec<String>, )

source

fn check_no_compiler_crash(&self, proc_res: &ProcRes, should_ice: bool)

source

fn check_forbid_output(&self, output_to_check: &str, proc_res: &ProcRes)

source

fn check_expected_errors(&self, expected_errors: Vec<Error>, proc_res: &ProcRes)

source

fn is_unexpected_compiler_message( &self, actual_error: &Error, expect_help: bool, expect_note: bool, ) -> bool

Returns true if we should report an error about actual_error, which did not match any of the expected error. We always require errors/warnings to be explicitly listed, but only require helps/notes if there are explicit helps/notes given.

source

fn should_emit_metadata(&self, pm: Option<PassMode>) -> Emit

source

fn compile_test(&self, will_execute: WillExecute, emit: Emit) -> ProcRes

source

fn compile_test_with_passes( &self, will_execute: WillExecute, emit: Emit, passes: Vec<String>, ) -> ProcRes

source

fn compile_test_general( &self, will_execute: WillExecute, emit: Emit, local_pm: Option<PassMode>, passes: Vec<String>, ) -> ProcRes

source

fn document(&self, root_out_dir: &Path, root_testpaths: &TestPaths) -> ProcRes

root_out_dir and root_testpaths refer to the parameters of the actual test being run. Auxiliaries, no matter how deep, have the same root_out_dir and root_testpaths.

source

fn exec_compiled_test(&self) -> ProcRes

source

fn exec_compiled_test_general( &self, env_extra: &[(&str, &str)], delete_after_success: bool, ) -> ProcRes

source

fn compute_aux_test_paths(&self, of: &TestPaths, rel_ab: &str) -> TestPaths

For each aux-build: foo/bar annotation, we check to find the file in an auxiliary directory relative to the test itself (not any intermediate auxiliaries).

source

fn is_vxworks_pure_static(&self) -> bool

source

fn is_vxworks_pure_dynamic(&self) -> bool

source

fn aux_output_dir(&self) -> PathBuf

source

fn build_all_auxiliary( &self, of: &TestPaths, aux_dir: &Path, rustc: &mut Command, )

source

fn compose_and_run_compiler( &self, rustc: Command, input: Option<String>, root_testpaths: &TestPaths, ) -> ProcRes

root_testpaths refers to the path of the original test. the auxiliary and the test with an aux-build have the same root_testpaths.

source

fn build_auxiliary( &self, of: &TestPaths, source_path: &str, aux_dir: &Path, is_bin: bool, ) -> AuxType

Builds an aux dependency.

source

fn read2_abbreviated(&self, child: Child) -> (Output, Truncated)

source

fn compose_and_run( &self, command: Command, lib_path: &str, aux_path: Option<&str>, input: Option<String>, ) -> ProcRes

source

fn is_rustdoc(&self) -> bool

source

fn get_mir_dump_dir(&self) -> PathBuf

source

fn make_compile_args( &self, input_file: &Path, output_file: TargetLocation, emit: Emit, allow_unused: AllowUnused, link_to_aux: LinkToAux, passes: Vec<String>, ) -> Command

source

fn make_exe_name(&self) -> PathBuf

source

fn make_run_args(&self) -> ProcArgs

source

fn split_maybe_args(&self, argstr: &Option<String>) -> Vec<OsString>

source

fn make_cmdline(&self, command: &Command, libpath: &str) -> String

source

fn dump_output(&self, out: &str, err: &str)

source

fn dump_output_file(&self, out: &str, extension: &str)

source

fn make_out_name(&self, extension: &str) -> PathBuf

Creates a filename for output with the given extension. E.g., /.../testname.revision.mode/testname.extension.

source

fn aux_output_dir_name(&self) -> PathBuf

Gets the directory where auxiliary files are written. E.g., /.../testname.revision.mode/auxiliary/.

source

fn aux_bin_output_dir_name(&self) -> PathBuf

Gets the directory where auxiliary binaries are written. E.g., /.../testname.revision.mode/auxiliary/bin.

source

fn output_testname_unique(&self) -> PathBuf

Generates a unique name for the test, such as testname.revision.mode.

source

fn safe_revision(&self) -> Option<&str>

The revision, ignored for incremental compilation since it wants all revisions in the same directory.

source

fn output_base_dir(&self) -> PathBuf

Gets the absolute path to the directory where all output for the given test/revision should reside. E.g., /path/to/build/host-triple/test/ui/relative/testname.revision.mode/.

source

fn output_base_name(&self) -> PathBuf

Gets the absolute path to the base filename used as output for the given test/revision. E.g., /.../relative/testname.revision.mode/testname.

source

fn maybe_dump_to_stdout(&self, out: &str, err: &str)

source

fn error(&self, err: &str)

source

fn fatal(&self, err: &str) -> !

source

fn fatal_proc_rec(&self, err: &str, proc_res: &ProcRes) -> !

source

fn fatal_proc_rec_with_ctx( &self, err: &str, proc_res: &ProcRes, on_failure: impl FnOnce(Self), ) -> !

source

fn compile_test_and_save_ir(&self) -> (ProcRes, PathBuf)

source

fn compile_test_and_save_assembly(&self) -> (ProcRes, PathBuf)

source

fn verify_with_filecheck(&self, output: &Path) -> ProcRes

source

fn charset() -> &'static str

source

fn compare_to_default_rustdoc(&mut self, out_dir: &Path)

source

fn get_lines<P: AsRef<Path>>( &self, path: &P, other_files: Option<&mut Vec<String>>, ) -> Vec<usize>

source

fn check_rustdoc_test_option(&self, res: ProcRes)

This method is used for //@ check-test-line-numbers-match.

It checks that doctests line in the displayed doctest “name” matches where they are defined in source code.

source

fn force_color_svg(&self) -> bool

source

fn load_compare_outputs( &self, proc_res: &ProcRes, output_kind: TestOutput, explicit_format: bool, ) -> usize

source

fn normalize_output( &self, output: &str, custom_rules: &[(String, String)], ) -> String

source

fn normalize_platform_differences(output: &str) -> String

Normalize output differences across platforms. Generally changes Windows output to be more Unix-like.

Replaces backslashes in paths with forward slashes, and replaces CRLF line endings with LF.

source

fn expected_output_path(&self, kind: &str) -> PathBuf

source

fn load_expected_output(&self, kind: &str) -> String

source

fn load_expected_output_from_path(&self, path: &Path) -> Result<String, String>

source

fn delete_file(&self, file: &PathBuf)

source

fn compare_output(&self, stream: &str, actual: &str, expected: &str) -> usize

source

fn check_and_prune_duplicate_outputs( &self, proc_res: &ProcRes, modes: &[CompareMode], require_same_modes: &[CompareMode], )

source

fn create_stamp(&self)

source

fn init_incremental_test(&self)

source

fn aggressive_rm_rf(&self, path: &Path) -> Result<()>

Trait Implementations§

source§

impl<'test> Clone for TestCx<'test>

source§

fn clone(&self) -> TestCx<'test>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'test> Copy for TestCx<'test>

Auto Trait Implementations§

§

impl<'test> Freeze for TestCx<'test>

§

impl<'test> RefUnwindSafe for TestCx<'test>

§

impl<'test> Send for TestCx<'test>

§

impl<'test> Sync for TestCx<'test>

§

impl<'test> Unpin for TestCx<'test>

§

impl<'test> UnwindSafe for TestCx<'test>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 40 bytes