Switch ui tests to trybuild

This commit is contained in:
David Tolnay 2019-05-04 14:52:16 -07:00
parent 7c20916f53
commit 8d7f731c2d
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
15 changed files with 3 additions and 98 deletions

View File

@ -4,8 +4,6 @@ matrix:
include:
- rust: nightly
script:
- cargo build
- cargo build --manifest-path tests/deps/Cargo.toml
- cargo test
- cargo test --features preserve_order
- cargo test --features arbitrary_precision

View File

@ -23,10 +23,10 @@ ryu = "0.2"
[dev-dependencies]
automod = "0.1"
compiletest_rs = { version = "0.3", features = ["stable"] }
serde_bytes = "0.11"
serde_derive = "1.0"
serde_stacker = "0.1"
trybuild = "1.0"
[package.metadata.docs.rs]
features = ["raw_value", "unbounded_depth"]

View File

@ -1,19 +1,5 @@
extern crate compiletest_rs as compiletest;
#[test]
fn ui() {
compiletest::run_tests(&compiletest::Config {
mode: compiletest::common::Mode::Ui,
src_base: std::path::PathBuf::from("tests/ui"),
target_rustcflags: Some(String::from(
"\
--edition=2018 \
-L tests/deps/target/debug/deps \
-Z unstable-options \
--extern serde_json \
",
)),
build_base: std::path::PathBuf::from("target/ui"),
..Default::default()
});
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");
}

View File

@ -1,13 +0,0 @@
[package]
name = "serde_test_suite_deps"
version = "0.0.0"
authors = ["David Tolnay <dtolnay@gmail.com>"]
publish = false
[workspace]
[features]
arbitrary_precision = ["serde_json/arbitrary_precision"]
[dependencies]
serde_json = { path = "../.." }

View File

@ -1,3 +0,0 @@
#![feature(/*=============================================]
#![=== Serde test suite requires a nightly compiler. ===]
#![====================================================*/)]

View File

@ -5,6 +5,3 @@ error: unexpected end of macro invocation
| ^^^^^^^^^^^^^^^ missing tokens in macro arguments
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error

View File

@ -5,6 +5,3 @@ error: unexpected end of macro invocation
| ^^^^^^^^^^^^^^^^^ missing tokens in macro arguments
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error

View File

@ -4,6 +4,4 @@ error[E0425]: cannot find value `x` in this scope
4 | json!({ "a" : x });
| ^ not found in this scope
error: aborting due to previous error
For more information about this error, try `rustc --explain E0425`.

View File

@ -5,6 +5,3 @@ error: unexpected end of macro invocation
| ^^^^^^^^^^^^^^^^^^^ missing tokens in macro arguments
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error

View File

@ -4,6 +4,4 @@ error[E0609]: no field `s` on type `&'static str`
4 | json!({ "".s : true });
| ^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0609`.

View File

@ -3,6 +3,3 @@ error: no rules expected the token `=>`
|
4 | json!([ true => ]);
| ^^ no rules expected this token in macro call
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: no rules expected the token `=>`
|
4 | json!({ "k": true => });
| ^^ no rules expected this token in macro call
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: no rules expected the token `:`
|
4 | json!({ : true });
| ^ no rules expected this token in macro call
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: no rules expected the token `,`
|
4 | json!({ "a" , "b": true });
| ^ no rules expected this token in macro call
error: aborting due to previous error

View File

@ -1,38 +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 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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.
cd "$(dirname "${BASH_SOURCE[0]}")"
BUILD_DIR="../../target/ui"
for testcase in *.rs; do
STDERR_NAME="${testcase/%.rs/.stderr}"
STDOUT_NAME="${testcase/%.rs/.stdout}"
if [ -f "$BUILD_DIR/$STDOUT_NAME" ] && \
! (diff "$BUILD_DIR/$STDOUT_NAME" "$STDOUT_NAME" >& /dev/null); then
echo "updating $STDOUT_NAME"
cp "$BUILD_DIR/$STDOUT_NAME" "$STDOUT_NAME"
fi
if [ -f "$BUILD_DIR/$STDERR_NAME" ] && \
! (diff "$BUILD_DIR/$STDERR_NAME" "$STDERR_NAME" >& /dev/null); then
echo "updating $STDERR_NAME"
cp "$BUILD_DIR/$STDERR_NAME" "$STDERR_NAME"
fi
done