From f29daa6dcaf4f664173a010eb0bf7b39b65f034b Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Thu, 26 Sep 2019 21:30:32 +0900 Subject: [PATCH] Use trybuild instead of compiletest --- Cargo.toml | 2 +- azure-pipelines.yml | 9 ++--- compiletest.sh | 3 +- tests/compiletest.rs | 29 +++------------ tests/ui/auto_enum/args.stderr | 3 -- tests/ui/auto_enum/attribute.stderr | 3 -- tests/ui/auto_enum/compile-fail.stderr | 2 -- tests/ui/auto_enum/marker.stderr | 3 -- tests/ui/auto_enum/rejected-by-rustc.stderr | 3 -- tests/ui/enum_derive/args.stderr | 3 -- tests/ui/enum_derive/ty_impls.stderr | 3 -- tests/ui/enum_derive/variant.stderr | 3 -- tests/ui/update-all-references.sh | 24 ------------- tests/ui/update-references.sh | 40 --------------------- 14 files changed, 9 insertions(+), 121 deletions(-) delete mode 100644 tests/ui/update-all-references.sh delete mode 100644 tests/ui/update-references.sh diff --git a/Cargo.toml b/Cargo.toml index 6b4f7382..4fdf076c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ auto_enums_core = { version = "=0.6.3", path = "core", default-features = false auto_enums_derive = { version = "=0.6.3", path = "derive", default-features = false } [dev-dependencies] -compiletest = { version = "=0.3.22", package = "compiletest_rs", features = ["stable", "tmp"] } +trybuild = "1.0" [features] # Default features. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ecd698dd..519ccd88 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -48,10 +48,7 @@ jobs: parameters: toolchain: nightly - script: | - cargo clean - cargo test -p auto_enums --all-features --test compiletest - env: - RUSTFLAGS: -Dwarnings --cfg compiletest + RUSTFLAGS='-Dwarnings --cfg compiletest' cargo test -p auto_enums --all-features --test compiletest displayName: compiletest - job: clippy @@ -124,7 +121,5 @@ jobs: parameters: toolchain: nightly - script: | - cargo doc --no-deps --all --all-features - env: - RUSTDOCFLAGS: -Dwarnings + RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all --all-features displayName: cargo doc diff --git a/compiletest.sh b/compiletest.sh index b97ef2b0..3e53ae47 100644 --- a/compiletest.sh +++ b/compiletest.sh @@ -8,4 +8,5 @@ # . ./compiletest.sh # ``` -rm -rf target/debug/deps/libauto_enums* && RUSTFLAGS='--cfg compiletest' cargo +nightly test -p auto_enums --all-features --test compiletest +TRYBUILD=overwrite RUSTFLAGS='--cfg compiletest' cargo +nightly test -p auto_enums --all-features --test compiletest +# RUSTFLAGS='--cfg compiletest' cargo +nightly test -p auto_enums --all-features --test compiletest diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 6a1bdff9..9027b567 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -6,30 +6,9 @@ feature = "try_trait", ))] -use std::{env, path::PathBuf}; - -fn run_mode(mode: &'static str) { - let mut config = compiletest::Config::default(); - config.mode = mode.parse().expect("invalid mode"); - let mut me = env::current_exe().unwrap(); - me.pop(); - config.target_rustcflags = Some(format!( - "--edition=2018 \ - -Z unstable-options \ - --extern auto_enums \ - -L {}", - me.display() - )); - let src = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - config.src_base = src.join("tests").join(mode); - - me.pop(); - me.pop(); - config.build_base = me.join("tests").join(mode); - compiletest::run_tests(&config); -} - #[test] -fn compiletest() { - run_mode("ui"); +fn ui() { + let t = trybuild::TestCases::new(); + t.compile_fail("tests/ui/auto_enum/*.rs"); + t.compile_fail("tests/ui/enum_derive/*.rs"); } diff --git a/tests/ui/auto_enum/args.stderr b/tests/ui/auto_enum/args.stderr index 82ce1d01..9c340dcc 100644 --- a/tests/ui/auto_enum/args.stderr +++ b/tests/ui/auto_enum/args.stderr @@ -45,6 +45,3 @@ error: expected `,` | 67 | #[auto_enum(marker = f t, Iterator)] //~ ERROR expected `,` | ^ - -error: aborting due to 8 previous errors - diff --git a/tests/ui/auto_enum/attribute.stderr b/tests/ui/auto_enum/attribute.stderr index eed26622..5418bbf2 100644 --- a/tests/ui/auto_enum/attribute.stderr +++ b/tests/ui/auto_enum/attribute.stderr @@ -15,6 +15,3 @@ error: #[rec] has been removed and replaced with #[nested] | 32 | #[rec] //~ ERROR #[rec] has been removed and replaced with #[nested] | ^^^^^^ - -error: aborting due to 3 previous errors - diff --git a/tests/ui/auto_enum/compile-fail.stderr b/tests/ui/auto_enum/compile-fail.stderr index 6d5188eb..26810ddb 100644 --- a/tests/ui/auto_enum/compile-fail.stderr +++ b/tests/ui/auto_enum/compile-fail.stderr @@ -39,6 +39,4 @@ error[E0061]: this function takes 1 parameter but 2 parameters were supplied | defined here | expected 1 parameter -error: aborting due to 5 previous errors - For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/auto_enum/marker.stderr b/tests/ui/auto_enum/marker.stderr index bc8f64ef..80f47873 100644 --- a/tests/ui/auto_enum/marker.stderr +++ b/tests/ui/auto_enum/marker.stderr @@ -9,6 +9,3 @@ error: cannot find macro `marker` in this scope | 29 | 2 => return marker!(1..9), //~ ERROR cannot find macro `marker!` in this scope | ^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/auto_enum/rejected-by-rustc.stderr b/tests/ui/auto_enum/rejected-by-rustc.stderr index 37fb8914..bcff0765 100644 --- a/tests/ui/auto_enum/rejected-by-rustc.stderr +++ b/tests/ui/auto_enum/rejected-by-rustc.stderr @@ -12,6 +12,3 @@ help: try placing this code inside a block | error: `#[auto_enum]` is required two or more branches or marker macros in total, there is no branch or marker macro in this statement - -error: aborting due to 2 previous errors - diff --git a/tests/ui/enum_derive/args.stderr b/tests/ui/enum_derive/args.stderr index e608b0d5..0d3ebfb5 100644 --- a/tests/ui/enum_derive/args.stderr +++ b/tests/ui/enum_derive/args.stderr @@ -21,6 +21,3 @@ error: expected `,` | 25 | #[enum_derive(Clone Foo)] //~ ERROR expected `,` | ^^^ - -error: aborting due to 4 previous errors - diff --git a/tests/ui/enum_derive/ty_impls.stderr b/tests/ui/enum_derive/ty_impls.stderr index fb4dfcff..b066900a 100644 --- a/tests/ui/enum_derive/ty_impls.stderr +++ b/tests/ui/enum_derive/ty_impls.stderr @@ -7,6 +7,3 @@ error: `enum_derive(Transpose)` all fields need to be generics 13 | | B(B), 14 | | } | |_^ - -error: aborting due to previous error - diff --git a/tests/ui/enum_derive/variant.stderr b/tests/ui/enum_derive/variant.stderr index 0d5356dd..66aa0d5f 100644 --- a/tests/ui/enum_derive/variant.stderr +++ b/tests/ui/enum_derive/variant.stderr @@ -33,6 +33,3 @@ error: cannot be implemented for enums with no variants | 38 | enum Enum7 {} //~ ERROR cannot be implemented for enums with less than two variants | ^^^^^^^^^^^^^ - -error: aborting due to 6 previous errors - diff --git a/tests/ui/update-all-references.sh b/tests/ui/update-all-references.sh deleted file mode 100644 index 207a562c..00000000 --- a/tests/ui/update-all-references.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -# A script to update the references for all tests. The idea is that -# you do a run, which will generate files in the build directory -# containing the (normalized) actual output of the compiler. You then -# run this script, which will copy those files over. If you find -# yourself manually editing a foo.stderr file, you're doing it wrong. -# -# See all `update-references.sh`, if you just want to update a single test. - -MY_DIR=$(dirname $0) -cd $MY_DIR -find . -name '*.rs' | xargs ./update-references.sh -cd - diff --git a/tests/ui/update-references.sh b/tests/ui/update-references.sh deleted file mode 100644 index 78836900..00000000 --- a/tests/ui/update-references.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# -# Copyright 2015 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -# A script to update the references for particular tests. The idea is -# that you do a run, which will generate files in the build directory -# containing the (normalized) actual output of the compiler. This -# script will then copy that output and replace the "expected output" -# files. You can then commit the changes. -# -# If you find yourself manually editing a foo.stderr file, you're -# doing it wrong. - -MYDIR=$(dirname $0) - -BUILD_DIR="../../target/tests/ui" - -while [[ "$1" != "" ]]; do - STDERR_NAME="${1/%.rs/.stderr}" - STDOUT_NAME="${1/%.rs/.stdout}" - shift - if [ -f $BUILD_DIR/$STDOUT_NAME ] && \ - ! (diff $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME >& /dev/null); then - echo updating $MYDIR/$STDOUT_NAME - cp $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME - fi - if [ -f $BUILD_DIR/$STDERR_NAME ] && \ - ! (diff $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME >& /dev/null); then - echo updating $MYDIR/$STDERR_NAME - cp $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME - fi -done