Skip to content

Commit

Permalink
Auto merge of #63408 - Centril:rollup-skqrez3, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - #62672 (Deprecate `try!` macro)
 - #62950 (Check rustbook links on all platforms when running locally)
 - #63114 (Remove gensym in format_args)
 - #63397 (Add tests for some ICEs)
 - #63403 (Improve test output)
 - #63404 (enable flt2dec tests in Miri)
 - #63407 (reduce some test sizes in Miri)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Aug 9, 2019
2 parents 813a3a5 + 4e3c209 commit 534b423
Show file tree
Hide file tree
Showing 44 changed files with 538 additions and 99 deletions.
26 changes: 23 additions & 3 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use build_helper::t;
use crate::Mode;
use crate::Compiler;
use crate::builder::{Step, RunConfig, ShouldRun, Builder};
use crate::util::{exe, add_lib_path};
use crate::util::{exe, add_lib_path, CiEnv};
use crate::compile;
use crate::channel::GitInfo;
use crate::channel;
Expand Down Expand Up @@ -279,11 +279,26 @@ pub fn prepare_tool_cargo(
cargo
}

fn rustbook_features() -> Vec<String> {
let mut features = Vec::new();

// Due to CI budged and risk of spurious failures we want to limit jobs running this check.
// At same time local builds should run it regardless of the platform.
// `CiEnv::None` means it's local build and `CHECK_LINKS` is defined in x86_64-gnu-tools to
// explicitly enable it on single job
if CiEnv::current() == CiEnv::None || env::var("CHECK_LINKS").is_ok() {
features.push("linkcheck".to_string());
}

features
}

macro_rules! bootstrap_tool {
($(
$name:ident, $path:expr, $tool_name:expr
$(,llvm_tools = $llvm:expr)*
$(,is_external_tool = $external:expr)*
$(,features = $features:expr)*
;
)+) => {
#[derive(Copy, PartialEq, Eq, Clone)]
Expand Down Expand Up @@ -350,7 +365,12 @@ macro_rules! bootstrap_tool {
} else {
SourceType::InTree
},
extra_features: Vec::new(),
extra_features: {
// FIXME(#60643): avoid this lint by using `_`
let mut _tmp = Vec::new();
$(_tmp.extend($features);)*
_tmp
},
}).expect("expected to build -- essential tool")
}
}
Expand All @@ -359,7 +379,7 @@ macro_rules! bootstrap_tool {
}

bootstrap_tool!(
Rustbook, "src/tools/rustbook", "rustbook";
Rustbook, "src/tools/rustbook", "rustbook", features = rustbook_features();
UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen";
Tidy, "src/tools/tidy", "tidy";
Linkchecker, "src/tools/linkchecker", "linkchecker";
Expand Down
3 changes: 3 additions & 0 deletions src/ci/docker/x86_64-gnu-tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ COPY x86_64-gnu-tools/checkregression.py /tmp/
COPY x86_64-gnu-tools/checktools.sh /tmp/
COPY x86_64-gnu-tools/repo.sh /tmp/

# Run rustbook with `linkcheck` feature enabled
ENV CHECK_LINKS 1

ENV RUST_CONFIGURE_ARGS \
--build=x86_64-unknown-linux-gnu \
--save-toolstates=/tmp/toolstates.json
Expand Down
3 changes: 3 additions & 0 deletions src/liballoc/tests/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,10 @@ fn test_split_off_empty_left() {

#[test]
fn test_split_off_large_random_sorted() {
#[cfg(not(miri))] // Miri is too slow
let mut data = rand_data(1529);
#[cfg(miri)]
let mut data = rand_data(529);
// special case with maximum height.
data.sort();

Expand Down
28 changes: 26 additions & 2 deletions src/liballoc/tests/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn test_clone_eq() {
m.insert(1);
m.insert(2);

assert!(m.clone() == m);
assert_eq!(m.clone(), m);
}

#[test]
Expand All @@ -28,7 +28,7 @@ fn test_hash() {
y.insert(2);
y.insert(1);

assert!(hash(&x) == hash(&y));
assert_eq!(hash(&x), hash(&y));
}

fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F)
Expand Down Expand Up @@ -69,6 +69,11 @@ fn test_intersection() {
check_intersection(&[11, 1, 3, 77, 103, 5, -5],
&[2, 11, 77, -9, -42, 5, 3],
&[3, 5, 11, 77]);

if cfg!(miri) { // Miri is too slow
return;
}

let large = (0..1000).collect::<Vec<_>>();
check_intersection(&[], &large, &[]);
check_intersection(&large, &[], &[]);
Expand Down Expand Up @@ -98,6 +103,11 @@ fn test_difference() {
check_difference(&[-5, 11, 22, 33, 40, 42],
&[-12, -5, 14, 23, 34, 38, 39, 50],
&[11, 22, 33, 40, 42]);

if cfg!(miri) { // Miri is too slow
return;
}

let large = (0..1000).collect::<Vec<_>>();
check_difference(&[], &large, &[]);
check_difference(&[-1], &large, &[-1]);
Expand Down Expand Up @@ -166,6 +176,17 @@ fn test_is_subset() {
assert_eq!(is_subset(&[1, 2], &[1]), false);
assert_eq!(is_subset(&[1, 2], &[1, 2]), true);
assert_eq!(is_subset(&[1, 2], &[2, 3]), false);
assert_eq!(is_subset(&[-5, 11, 22, 33, 40, 42],
&[-12, -5, 14, 23, 11, 34, 22, 38, 33, 42, 39, 40]),
true);
assert_eq!(is_subset(&[-5, 11, 22, 33, 40, 42],
&[-12, -5, 14, 23, 34, 38, 22, 11]),
false);

if cfg!(miri) { // Miri is too slow
return;
}

let large = (0..1000).collect::<Vec<_>>();
assert_eq!(is_subset(&[], &large), true);
assert_eq!(is_subset(&large, &[]), false);
Expand Down Expand Up @@ -371,7 +392,10 @@ fn test_split_off_empty_left() {

#[test]
fn test_split_off_large_random_sorted() {
#[cfg(not(miri))] // Miri is too slow
let mut data = rand_data(1529);
#[cfg(miri)]
let mut data = rand_data(529);
// special case with maximum height.
data.sort();

Expand Down
3 changes: 1 addition & 2 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ macro_rules! debug_assert_ne {
/// ```
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(since = "1.39.0", reason = "use the `?` operator instead")]
#[doc(alias = "?")]
macro_rules! r#try {
($expr:expr) => (match $expr {
Expand Down Expand Up @@ -767,7 +768,6 @@ pub(crate) mod builtin {
#[stable(feature = "rust1", since = "1.0.0")]
#[allow_internal_unstable(fmt_internals)]
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
pub macro format_args {
($fmt:expr) => ({ /* compiler built-in */ }),
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ })
Expand All @@ -779,7 +779,6 @@ pub(crate) mod builtin {
language use and is subject to change")]
#[allow_internal_unstable(fmt_internals)]
#[rustc_builtin_macro]
#[rustc_macro_transparency = "semitransparent"]
pub macro format_args_nl {
($fmt:expr) => ({ /* compiler built-in */ }),
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ })
Expand Down
1 change: 1 addition & 0 deletions src/libcore/tests/num/dec2flt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ fn infinity() {
fn zero() {
test_literal!(0.0);
test_literal!(1e-325);
#[cfg(not(miri))] // Miri is too slow
test_literal!(1e-326);
#[cfg(not(miri))] // Miri is too slow
test_literal!(1e-500);
Expand Down
7 changes: 6 additions & 1 deletion src/libcore/tests/num/flt2dec/estimator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ fn test_estimate_scaling_factor() {
assert_almost_eq!(estimate_scaling_factor(1, -1074), -323);
assert_almost_eq!(estimate_scaling_factor(0x1fffffffffffff, 971), 309);

for i in -1074..972 {
#[cfg(not(miri))] // Miri is too slow
let iter = -1074..972;
#[cfg(miri)]
let iter = (-1074..972).step_by(37);

for i in iter {
let expected = super::ldexp_f64(1.0, i).log10().ceil();
assert_almost_eq!(estimate_scaling_factor(1, i as i16), expected as i16);
}
Expand Down
16 changes: 14 additions & 2 deletions src/libcore/tests/num/flt2dec/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(not(miri))] // Miri does not implement ldexp, which most tests here need

use std::prelude::v1::*;
use std::{str, i16, f32, f64, fmt};

Expand Down Expand Up @@ -257,6 +255,7 @@ pub fn f32_shortest_sanity_test<F>(mut f: F) where F: FnMut(&Decoded, &mut [u8])
check_shortest!(f(minf32) => b"1", -44);
}

#[cfg(not(miri))] // Miri is too slow
pub fn f32_exact_sanity_test<F>(mut f: F)
where F: FnMut(&Decoded, &mut [u8], i16) -> (usize, i16) {
let minf32 = ldexp_f32(1.0, -149);
Expand Down Expand Up @@ -362,6 +361,7 @@ pub fn f64_shortest_sanity_test<F>(mut f: F) where F: FnMut(&Decoded, &mut [u8])
check_shortest!(f(minf64) => b"5", -323);
}

#[cfg(not(miri))] // Miri is too slow
pub fn f64_exact_sanity_test<F>(mut f: F)
where F: FnMut(&Decoded, &mut [u8], i16) -> (usize, i16) {
let minf64 = ldexp_f64(1.0, -1074);
Expand Down Expand Up @@ -553,6 +553,10 @@ pub fn to_shortest_str_test<F>(mut f_: F)
assert_eq!(to_string(f, minf64, Minus, 324, false), format!("0.{:0>323}5", ""));
assert_eq!(to_string(f, minf64, Minus, 325, false), format!("0.{:0>323}50", ""));

if cfg!(miri) { // Miri is too slow
return;
}

// very large output
assert_eq!(to_string(f, 1.1, Minus, 80000, false), format!("1.1{:0>79999}", ""));
}
Expand Down Expand Up @@ -807,6 +811,10 @@ pub fn to_exact_exp_str_test<F>(mut f_: F)
"1.401298464324817070923729583289916131280261941876515771757068283\
8897910826858606014866381883621215820312500000000000000000000000e-45");

if cfg!(miri) { // Miri is too slow
return;
}

assert_eq!(to_string(f, f64::MAX, Minus, 1, false), "2e308");
assert_eq!(to_string(f, f64::MAX, Minus, 2, false), "1.8e308");
assert_eq!(to_string(f, f64::MAX, Minus, 4, false), "1.798e308");
Expand Down Expand Up @@ -1040,6 +1048,10 @@ pub fn to_exact_fixed_str_test<F>(mut f_: F)
assert_eq!(to_string(f, f32::MAX, Minus, 2, false),
"340282346638528859811704183484516925440.00");

if cfg!(miri) { // Miri is too slow
return;
}

let minf32 = ldexp_f32(1.0, -149);
assert_eq!(to_string(f, minf32, Minus, 0, false), "0");
assert_eq!(to_string(f, minf32, Minus, 1, false), "0.0");
Expand Down
23 changes: 19 additions & 4 deletions src/libcore/tests/num/flt2dec/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,13 @@ pub fn f32_exhaustive_equivalence_test<F, G>(f: F, g: G, k: usize)
#[test]
fn shortest_random_equivalence_test() {
use core::num::flt2dec::strategy::dragon::format_shortest as fallback;
f64_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, 10_000);
f32_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, 10_000);
#[cfg(not(miri))] // Miri is too slow
const N: usize = 10_000;
#[cfg(miri)]
const N: usize = 10;

f64_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, N);
f32_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, N);
}

#[test] #[ignore] // it is too expensive
Expand Down Expand Up @@ -138,17 +143,27 @@ fn shortest_f64_hard_random_equivalence_test() {
#[test]
fn exact_f32_random_equivalence_test() {
use core::num::flt2dec::strategy::dragon::format_exact as fallback;
#[cfg(not(miri))] // Miri is too slow
const N: usize = 1_000;
#[cfg(miri)]
const N: usize = 3;

for k in 1..21 {
f32_random_equivalence_test(|d, buf| format_exact_opt(d, buf, i16::MIN),
|d, buf| fallback(d, buf, i16::MIN), k, 1_000);
|d, buf| fallback(d, buf, i16::MIN), k, N);
}
}

#[test]
fn exact_f64_random_equivalence_test() {
use core::num::flt2dec::strategy::dragon::format_exact as fallback;
#[cfg(not(miri))] // Miri is too slow
const N: usize = 1_000;
#[cfg(miri)]
const N: usize = 3;

for k in 1..21 {
f64_random_equivalence_test(|d, buf| format_exact_opt(d, buf, i16::MIN),
|d, buf| fallback(d, buf, i16::MIN), k, 1_000);
|d, buf| fallback(d, buf, i16::MIN), k, N);
}
}
1 change: 1 addition & 0 deletions src/libcore/tests/num/flt2dec/strategy/dragon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fn shortest_sanity_test() {
}

#[test]
#[cfg(not(miri))] // Miri is too slow
fn exact_sanity_test() {
// This test ends up running what I can only assume is some corner-ish case
// of the `exp2` library function, defined in whatever C runtime we're
Expand Down
1 change: 1 addition & 0 deletions src/libcore/tests/num/flt2dec/strategy/grisu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ fn shortest_sanity_test() {
}

#[test]
#[cfg(not(miri))] // Miri is too slow
fn exact_sanity_test() {
// See comments in dragon.rs's exact_sanity_test for why this test is
// ignored on MSVC
Expand Down
18 changes: 9 additions & 9 deletions src/libcore/tests/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ use core::result::Result::{Ok, Err};
#[test]
fn test_position() {
let b = [1, 2, 3, 5, 5];
assert!(b.iter().position(|&v| v == 9) == None);
assert!(b.iter().position(|&v| v == 5) == Some(3));
assert!(b.iter().position(|&v| v == 3) == Some(2));
assert!(b.iter().position(|&v| v == 0) == None);
assert_eq!(b.iter().position(|&v| v == 9), None);
assert_eq!(b.iter().position(|&v| v == 5), Some(3));
assert_eq!(b.iter().position(|&v| v == 3), Some(2));
assert_eq!(b.iter().position(|&v| v == 0), None);
}

#[test]
fn test_rposition() {
let b = [1, 2, 3, 5, 5];
assert!(b.iter().rposition(|&v| v == 9) == None);
assert!(b.iter().rposition(|&v| v == 5) == Some(4));
assert!(b.iter().rposition(|&v| v == 3) == Some(2));
assert!(b.iter().rposition(|&v| v == 0) == None);
assert_eq!(b.iter().rposition(|&v| v == 9), None);
assert_eq!(b.iter().rposition(|&v| v == 5), Some(4));
assert_eq!(b.iter().rposition(|&v| v == 3), Some(2));
assert_eq!(b.iter().rposition(|&v| v == 0), None);
}

#[test]
Expand Down Expand Up @@ -1153,7 +1153,7 @@ fn test_rotate_right() {
}

#[test]
#[cfg(not(miri))]
#[cfg(not(miri))] // Miri is too slow
fn brute_force_rotate_test_0() {
// In case of edge cases involving multiple algorithms
let n = 300;
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/tests/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use core::time::Duration;

#[test]
fn creation() {
assert!(Duration::from_secs(1) != Duration::from_secs(0));
assert_ne!(Duration::from_secs(1), Duration::from_secs(0));
assert_eq!(Duration::from_secs(1) + Duration::from_secs(2),
Duration::from_secs(3));
assert_eq!(Duration::from_millis(10) + Duration::from_secs(4),
Expand Down
Loading

0 comments on commit 534b423

Please sign in to comment.