Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
316 changes: 158 additions & 158 deletions src/tools/compiletest/src/common.rs

Large diffs are not rendered by default.

204 changes: 102 additions & 102 deletions src/tools/compiletest/src/directives.rs

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/tools/compiletest/src/directives/auxiliary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ mod tests;

/// The value of an `aux-crate` directive.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct AuxCrate {
pub(crate) struct AuxCrate {
/// Contains `--extern` modifiers, if any. See the tracking issue for more
/// info: <https://github.com/rust-lang/rust/issues/98405>
/// With `aux-crate: noprelude:foo=bar.rs` this will be `noprelude`.
pub extern_modifiers: Option<String>,
pub(crate) extern_modifiers: Option<String>,
/// With `aux-crate: foo=bar.rs` this will be `foo`.
/// With `aux-crate: noprelude:foo=bar.rs` this will be `foo`.
pub name: String,
pub(crate) name: String,
/// With `aux-crate: foo=bar.rs` this will be `bar.rs`.
pub path: String,
pub(crate) path: String,
}

/// The value of a `proc-macro` directive.
Expand All @@ -31,9 +31,9 @@ pub(crate) struct ProcMacro {
/// Contains `--extern` modifiers, if any. See the tracking issue for more
/// info: <https://github.com/rust-lang/rust/issues/98405>
/// With `proc-macro: noprelude:bar.rs` this will be `noprelude`.
pub extern_modifiers: Option<String>,
pub(crate) extern_modifiers: Option<String>,
/// With `proc-macro: bar.rs` this will be `bar.rs`.
pub path: String,
pub(crate) path: String,
}

/// Properties parsed from `aux-*` test directives.
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/edition.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::fatal;

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Edition {
pub(crate) enum Edition {
// Note that the ordering here is load-bearing, as we want the future edition to be greater than
// any year-based edition.
Year(u32),
Expand All @@ -23,7 +23,7 @@ impl From<u32> for Edition {
}
}

pub fn parse_edition(mut input: &str) -> Edition {
pub(crate) fn parse_edition(mut input: &str) -> Edition {
input = input.trim();
if input == "future" {
Edition::Future
Expand Down
20 changes: 10 additions & 10 deletions src/tools/compiletest/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use regex::Regex;
use tracing::*;

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum ErrorKind {
pub(crate) enum ErrorKind {
Help,
Error,
Note,
Expand All @@ -21,7 +21,7 @@ pub enum ErrorKind {
}

impl ErrorKind {
pub fn from_compiler_str(s: &str) -> ErrorKind {
pub(crate) fn from_compiler_str(s: &str) -> ErrorKind {
match s {
"help" => ErrorKind::Help,
"error" | "error: internal compiler error" => ErrorKind::Error,
Expand All @@ -45,7 +45,7 @@ impl ErrorKind {
})
}

pub fn expect_from_user_str(s: &str) -> ErrorKind {
pub(crate) fn expect_from_user_str(s: &str) -> ErrorKind {
ErrorKind::from_user_str(s).unwrap_or_else(|| {
panic!(
"unexpected diagnostic kind `{s}`, expected \
Expand All @@ -70,16 +70,16 @@ impl fmt::Display for ErrorKind {
}

#[derive(Debug)]
pub struct Error {
pub line_num: Option<usize>,
pub column_num: Option<usize>,
pub(crate) struct Error {
pub(crate) line_num: Option<usize>,
pub(crate) column_num: Option<usize>,
/// What kind of message we expect (e.g., warning, error, suggestion).
pub kind: ErrorKind,
pub msg: String,
pub(crate) kind: ErrorKind,
pub(crate) msg: String,
/// For some `Error`s, like secondary lines of multi-line diagnostics, line annotations
/// are not mandatory, even if they would otherwise be mandatory for primary errors.
/// Only makes sense for "actual" errors, not for "expected" errors.
pub require_annotation: bool,
pub(crate) require_annotation: bool,
}

/// Looks for either "//~| KIND MESSAGE" or "//~^^... KIND MESSAGE"
Expand All @@ -92,7 +92,7 @@ pub struct Error {
///
/// If revision is not None, then we look
/// for `//[X]~` instead, where `X` is the current revision.
pub fn load_errors(testfile: &Utf8Path, revision: Option<&str>) -> Vec<Error> {
pub(crate) fn load_errors(testfile: &Utf8Path, revision: Option<&str>) -> Vec<Error> {
let rdr = BufReader::new(File::open(testfile.as_std_path()).unwrap());

// `last_nonfollow_error` tracks the most recently seen
Expand Down
6 changes: 3 additions & 3 deletions src/tools/compiletest/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ struct DiagnosticCode {
code: String,
}

pub fn rustfix_diagnostics_only(output: &str) -> String {
pub(crate) fn rustfix_diagnostics_only(output: &str) -> String {
output
.lines()
.filter(|line| line.starts_with('{') && serde_json::from_str::<Diagnostic>(line).is_ok())
.collect()
}

pub fn extract_rendered(output: &str) -> String {
pub(crate) fn extract_rendered(output: &str) -> String {
output
.lines()
.filter_map(|line| {
Expand Down Expand Up @@ -137,7 +137,7 @@ pub fn extract_rendered(output: &str) -> String {
.collect()
}

pub fn parse_output(file_name: &str, output: &str) -> Vec<Error> {
pub(crate) fn parse_output(file_name: &str, output: &str) -> Vec<Error> {
let mut errors = Vec::new();
for line in output.lines() {
// Compiler can emit non-json lines in non-`--error-format=json` modes,
Expand Down
5 changes: 4 additions & 1 deletion src/tools/compiletest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#![crate_name = "compiletest"]
#![warn(unreachable_pub)]

#[cfg(test)]
mod tests;

// Public modules needed by the compiletest binary or by `rustdoc-gui-test`.
pub mod cli;
pub mod rustdoc_gui_test;

mod common;
mod debuggers;
mod diagnostics;
Expand All @@ -17,7 +21,6 @@ mod panic_hook;
mod raise_fd_limit;
mod read2;
mod runtest;
pub mod rustdoc_gui_test;
mod util;

use core::panic;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/output_capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt;
use std::panic::RefUnwindSafe;
use std::sync::Mutex;

pub trait ConsoleOut: fmt::Debug + RefUnwindSafe {
pub(crate) trait ConsoleOut: fmt::Debug + RefUnwindSafe {
fn write_fmt(&self, args: fmt::Arguments<'_>);
}

Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/raise_fd_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#[cfg(target_vendor = "apple")]
#[allow(non_camel_case_types)]
// FIXME(#139616): document caller contract.
pub unsafe fn raise_fd_limit() {
pub(crate) unsafe fn raise_fd_limit() {
use std::ptr::null_mut;
use std::{cmp, io};

Expand Down Expand Up @@ -54,4 +54,4 @@ pub unsafe fn raise_fd_limit() {
}

#[cfg(not(target_vendor = "apple"))]
pub unsafe fn raise_fd_limit() {}
pub(crate) unsafe fn raise_fd_limit() {}
12 changes: 6 additions & 6 deletions src/tools/compiletest/src/read2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ mod tests;
use std::io::{self, Write};
use std::process::{Child, Output};

pub use self::imp::read2;
use self::imp::read2;

#[derive(Copy, Clone, Debug)]
pub enum Truncated {
pub(crate) enum Truncated {
Yes,
No,
}

pub fn read2_abbreviated(
pub(crate) fn read2_abbreviated(
mut child: Child,
filter_paths_from_len: &[String],
) -> io::Result<(Output, Truncated)> {
Expand Down Expand Up @@ -138,7 +138,7 @@ mod imp {
use std::io::{self, Read};
use std::process::{ChildStderr, ChildStdout};

pub fn read2(
pub(crate) fn read2(
out_pipe: ChildStdout,
err_pipe: ChildStderr,
data: &mut dyn FnMut(bool, &mut Vec<u8>, bool),
Expand All @@ -160,7 +160,7 @@ mod imp {
use std::process::{ChildStderr, ChildStdout};
use std::{io, mem};

pub fn read2(
pub(crate) fn read2(
mut out_pipe: ChildStdout,
mut err_pipe: ChildStderr,
data: &mut dyn FnMut(bool, &mut Vec<u8>, bool),
Expand Down Expand Up @@ -247,7 +247,7 @@ mod imp {
done: bool,
}

pub fn read2(
pub(crate) fn read2(
out_pipe: ChildStdout,
err_pipe: ChildStderr,
data: &mut dyn FnMut(bool, &mut Vec<u8>, bool),
Expand Down
8 changes: 4 additions & 4 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn dylib_name(name: &str) -> String {
format!("{}{name}.{}", std::env::consts::DLL_PREFIX, std::env::consts::DLL_EXTENSION)
}

pub fn run(
pub(crate) fn run(
config: &Config,
stdout: &dyn ConsoleOut,
stderr: &dyn ConsoleOut,
Expand Down Expand Up @@ -181,7 +181,7 @@ pub fn run(
cx.create_stamp();
}

pub fn compute_stamp_hash(config: &Config) -> String {
pub(crate) fn compute_stamp_hash(config: &Config) -> String {
let mut hash = DefaultHasher::new();
config.stage_id.hash(&mut hash);
config.run.hash(&mut hash);
Expand Down Expand Up @@ -2985,7 +2985,7 @@ struct ProcArgs {
}

#[derive(Debug)]
pub struct ProcRes {
pub(crate) struct ProcRes {
status: ExitStatus,
stdout: String,
stderr: String,
Expand All @@ -2995,7 +2995,7 @@ pub struct ProcRes {

impl ProcRes {
#[must_use]
pub fn format_info(&self) -> String {
pub(crate) fn format_info(&self) -> String {
fn render(name: &str, contents: &str) -> String {
let contents = json::extract_rendered(contents);
let contents = contents.trim_end();
Expand Down
10 changes: 5 additions & 5 deletions src/tools/compiletest/src/runtest/compute_diff.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use std::collections::VecDeque;

#[derive(Debug, PartialEq)]
pub enum DiffLine {
pub(crate) enum DiffLine {
Context(String),
Expected(String),
Resulting(String),
}

#[derive(Debug, PartialEq)]
pub struct Mismatch {
pub line_number: u32,
pub lines: Vec<DiffLine>,
pub(crate) struct Mismatch {
pub(crate) line_number: u32,
pub(crate) lines: Vec<DiffLine>,
}

impl Mismatch {
Expand All @@ -20,7 +20,7 @@ impl Mismatch {
}

// Produces a diff between the expected output and actual output.
pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec<Mismatch> {
pub(crate) fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec<Mismatch> {
let mut line_number = 1;
let mut context_queue: VecDeque<&str> = VecDeque::with_capacity(context_size);
let mut lines_since_mismatch = context_size + 1;
Expand Down
10 changes: 5 additions & 5 deletions src/tools/compiletest/src/runtest/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use crate::directives::{LineNumber, line_directive};
use crate::runtest::ProcRes;

/// Representation of information to invoke a debugger and check its output
pub(super) struct DebuggerCommands {
pub(crate) struct DebuggerCommands {
/// Commands for the debuuger
pub commands: Vec<String>,
pub(crate) commands: Vec<String>,
/// Lines to insert breakpoints at
pub breakpoint_lines: Vec<LineNumber>,
pub(crate) breakpoint_lines: Vec<LineNumber>,
/// Contains the source line number to check and the line itself
check_lines: Vec<(LineNumber, String)>,
/// Source file name
Expand All @@ -22,7 +22,7 @@ pub(super) struct DebuggerCommands {
}

impl DebuggerCommands {
pub fn parse_from(
pub(crate) fn parse_from(
file: &Utf8Path,
debugger_prefix: &str,
test_revision: Option<&str>,
Expand Down Expand Up @@ -75,7 +75,7 @@ impl DebuggerCommands {
/// Given debugger output and lines to check, ensure that every line is
/// contained in the debugger output. The check lines need to be found in
/// order, but there can be extra lines between.
pub fn check_output(&self, debugger_run_result: &ProcRes) -> Result<(), String> {
pub(crate) fn check_output(&self, debugger_run_result: &ProcRes) -> Result<(), String> {
// (src_lineno, ck_line) that we did find
let mut found = vec![];
// (src_lineno, ck_line) that we couldn't find
Expand Down
12 changes: 6 additions & 6 deletions src/tools/compiletest/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use camino::{Utf8Path, Utf8PathBuf};
#[cfg(test)]
mod tests;

pub fn make_new_path(path: &str) -> String {
pub(crate) fn make_new_path(path: &str) -> String {
assert!(cfg!(windows));
// Windows just uses PATH as the library search path, so we have to
// maintain the current value while adding our own
Expand All @@ -16,14 +16,14 @@ pub fn make_new_path(path: &str) -> String {
}
}

pub fn lib_path_env_var() -> &'static str {
pub(crate) fn lib_path_env_var() -> &'static str {
"PATH"
}
fn path_div() -> &'static str {
";"
}

pub trait Utf8PathBufExt {
pub(crate) trait Utf8PathBufExt {
/// Append an extension to the path, even if it already has one.
fn with_extra_extension(&self, extension: &str) -> Utf8PathBuf;
}
Expand All @@ -44,7 +44,7 @@ impl Utf8PathBufExt for Utf8PathBuf {
}

/// The name of the environment variable that holds dynamic library locations.
pub fn dylib_env_var() -> &'static str {
pub(crate) fn dylib_env_var() -> &'static str {
if cfg!(any(windows, target_os = "cygwin")) {
"PATH"
} else if cfg!(target_vendor = "apple") {
Expand All @@ -60,7 +60,7 @@ pub fn dylib_env_var() -> &'static str {

/// Adds a list of lookup paths to `cmd`'s dynamic library lookup path.
/// If the dylib_path_var is already set for this cmd, the old value will be overwritten!
pub fn add_dylib_path(
pub(crate) fn add_dylib_path(
cmd: &mut Command,
paths: impl Iterator<Item = impl Into<std::path::PathBuf>>,
) {
Expand All @@ -70,7 +70,7 @@ pub fn add_dylib_path(
cmd.env(dylib_env_var(), env::join_paths(new_paths).unwrap());
}

pub fn copy_dir_all(src: &Utf8Path, dst: &Utf8Path) -> std::io::Result<()> {
pub(crate) fn copy_dir_all(src: &Utf8Path, dst: &Utf8Path) -> std::io::Result<()> {
std::fs::create_dir_all(dst.as_std_path())?;
for entry in std::fs::read_dir(src.as_std_path())? {
let entry = entry?;
Expand Down
Loading