Switch ui tests to trybuild

This commit is contained in:
David Tolnay 2019-05-03 23:23:02 -07:00
parent 28ce892617
commit 140f9beee7
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
98 changed files with 5 additions and 350 deletions

View File

@ -26,8 +26,6 @@ matrix:
- cargo build --no-default-features --features alloc
- cargo build --no-default-features --features rc,alloc
- cargo test --features derive,rc,unstable
- cd "${TRAVIS_BUILD_DIR}/test_suite/deps"
- cargo build
- cd "${TRAVIS_BUILD_DIR}/test_suite"
- cargo test --features unstable
- cd "${TRAVIS_BUILD_DIR}/test_suite/no_std"

View File

@ -35,7 +35,5 @@ for:
- cargo build --no-default-features --features alloc
- cargo build --no-default-features --features rc,alloc
- cargo test --features derive,rc,unstable
- cd %APPVEYOR_BUILD_FOLDER%\test_suite\deps
- cargo build
- cd %APPVEYOR_BUILD_FOLDER%\test_suite
- cargo test --features unstable

View File

@ -7,14 +7,12 @@ publish = false
[features]
unstable = ["serde/unstable"]
compiletest = ["compiletest_rs"]
[dev-dependencies]
fnv = "1.0"
rustc-serialize = "0.3.16"
select-rustc = "0.1"
serde = { path = "../serde", features = ["rc", "derive"] }
serde_derive = { path = "../serde_derive", features = ["deserialize_in_place"] }
serde_test = { path = "../serde_test" }
[dependencies]
compiletest_rs = { version = "0.3", optional = true, features = ["stable"] }
trybuild = "1.0"

View File

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

View File

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

View File

@ -1,21 +1,6 @@
#![cfg(feature = "compiletest")]
use compiletest_rs as compiletest;
#[rustc::attr(not(nightly), ignore)]
#[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 deps/target/debug/deps \
-Z unstable-options \
--extern serde_derive \
",
)),
build_base: std::path::PathBuf::from("../target/ui"),
..Default::default()
});
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/**/*.rs");
}

View File

@ -3,6 +3,3 @@ error: failed to parse borrowed lifetimes: "zzz"
|
5 | #[serde(borrow = "zzz")]
| ^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: duplicate borrowed lifetime `'a`
|
5 | #[serde(borrow = "'a + 'a")]
| ^^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: duplicate serde attribute `borrow`
|
8 | #[serde(borrow)]
| ^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: at least one lifetime must be borrowed
|
5 | #[serde(borrow = "")]
| ^^
error: aborting due to previous error

View File

@ -4,6 +4,3 @@ error: field `s` has no lifetimes to borrow
5 | / #[serde(borrow)]
6 | | s: String,
| |_____________^
error: aborting due to previous error

View File

@ -4,6 +4,3 @@ error: #[serde(borrow)] may only be used on newtype variants
8 | / #[serde(borrow)]
9 | | S { s: Str<'a> },
| |____________________^
error: aborting due to previous error

View File

@ -4,6 +4,3 @@ error: field `s` does not have lifetime 'b
5 | / #[serde(borrow = "'b")]
6 | | s: &'a str,
| |______________^
error: aborting due to previous error

View File

@ -7,6 +7,3 @@ error: enum tags `conflict` for type and content conflict with each other
7 | | B,
8 | | }
| |_^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: #[serde(flatten)] cannot be used on newtype structs
|
6 | struct Foo(#[serde(flatten)] HashMap<String, String>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: #[serde(flatten)] cannot be used on tuple structs
|
6 | struct Foo(u32, #[serde(flatten)] HashMap<String, String>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -9,6 +9,3 @@ error: variant field name `conflict` conflicts with internal tag
9 | | },
10 | | }
| |_^
error: aborting due to previous error

View File

@ -9,6 +9,3 @@ error: variant field name `conflict` conflicts with internal tag
9 | | },
10 | | }
| |_^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: #[serde(default)] can only be used on structs with named fields
|
5 | enum E {
| ^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: #[serde(default = "...")] can only be used on structs with named fields
|
5 | enum E {
| ^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: #[serde(default)] can only be used on structs with named fields
|
5 | struct T(u8, u8);
| ^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: #[serde(default = "...")] can only be used on structs with named fields
|
5 | struct T(u8, u8);
| ^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: unknown serde field attribute `serialize`
|
5 | #[serde(rename = "x", serialize = "y")]
| ^^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: duplicate serde attribute `rename`
|
5 | #[serde(rename(serialize = "x"), rename(serialize = "y"))]
| ^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: duplicate serde attribute `rename`
|
6 | #[serde(rename = "y")]
| ^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: duplicate serde attribute `rename`
|
5 | #[serde(rename(serialize = "x", serialize = "y"))]
| ^^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: duplicate serde attribute `rename`
|
6 | #[serde(rename(serialize = "y"))]
| ^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: duplicate serde attribute `serialize_with`
|
5 | #[serde(with = "w", serialize_with = "s")]
| ^^^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: #[serde(tag = "...", content = "...")] must be used together
|
4 | #[serde(content = "c")]
| ^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: #[serde(tag = "...")] cannot be used with tuple variants
|
6 | Tuple(u8, u8),
| ^^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -15,6 +15,3 @@ error: untagged enum cannot have #[serde(tag = "...", content = "...")]
|
5 | #[serde(tag = "t", content = "c")]
| ^^^^^^^
error: aborting due to 3 previous errors

View File

@ -9,6 +9,3 @@ error: untagged enum cannot have #[serde(content = "...")]
|
5 | #[serde(content = "c")]
| ^^^^^^^
error: aborting due to 2 previous errors

View File

@ -9,6 +9,3 @@ error: enum cannot be both untagged and internally tagged
|
5 | #[serde(tag = "type")]
| ^^^
error: aborting due to 2 previous errors

View File

@ -3,6 +3,3 @@ error: #[serde(untagged)] can only be used on enums
|
5 | struct S;
| ^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: expected serde rename attribute to be a string: `rename = "..."`
|
5 | #[serde(rename = true)]
| ^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: expected serde rename attribute to be a string: `rename = "..."`
|
5 | #[serde(rename = b'a')]
| ^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: expected serde rename attribute to be a string: `rename = "..."`
|
5 | #[serde(rename = b"byte string")]
| ^^^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: expected serde rename attribute to be a string: `rename = "..."`
|
5 | #[serde(rename = 'a')]
| ^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: expected serde rename attribute to be a string: `rename = "..."`
|
5 | #[serde(rename = 3.14)]
| ^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: expected serde rename attribute to be a string: `rename = "..."`
|
5 | #[serde(rename = 100)]
| ^^^
error: aborting due to previous error

View File

@ -9,6 +9,3 @@ error: #[serde(field_identifier)] and #[serde(variant_identifier)] cannot both b
|
4 | #[serde(field_identifier, variant_identifier)]
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View File

@ -3,6 +3,3 @@ error: #[serde(field_identifier)] can only be used on an enum
|
5 | struct S;
| ^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: #[serde(field_identifier)] may only contain unit variants
|
7 | B(u8, u8),
| ^^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: `Other` must be the last variant
|
7 | Other(String),
| ^^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -4,6 +4,3 @@ error: #[serde(other)] must be on a unit variant
7 | / #[serde(other)]
8 | | Other(u8, u8),
| |_________________^
error: aborting due to previous error

View File

@ -4,6 +4,3 @@ error: #[serde(other)] must be on the last variant
7 | / #[serde(other)]
8 | | Other,
| |_________^
error: aborting due to previous error

View File

@ -4,6 +4,3 @@ error: #[serde(other)] cannot appear on untagged enum
6 | / #[serde(other)]
7 | | Other,
| |_________^
error: aborting due to previous error

View File

@ -4,6 +4,3 @@ error: #[serde(other)] may not be used on a variant identifier
6 | / #[serde(other)]
7 | | Other,
| |_________^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: #[serde(variant_identifier)] can only be used on an enum
|
5 | struct S;
| ^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: #[serde(variant_identifier)] may only contain unit variants
|
7 | B(u8, u8),
| ^^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: malformed bound attribute, expected `bound(serialize = ..., deserialize =
|
5 | #[serde(bound(unknown))]
| ^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: malformed rename attribute, expected `rename(serialize = ..., deserialize
|
5 | #[serde(rename(unknown))]
| ^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: cannot deserialize when there is a lifetime parameter called 'de
|
4 | struct S<'de> {
| ^^^
error: aborting due to previous error

View File

@ -6,6 +6,3 @@ error: cannot deserialize a dynamically sized struct
6 | | slice: [u8],
7 | | }
| |_^
error: aborting due to previous error

View File

@ -7,6 +7,3 @@ error: field identifiers cannot be serialized
7 | | B,
8 | | }
| |_^
error: aborting due to previous error

View File

@ -7,6 +7,3 @@ error: variant identifiers cannot be serialized
7 | | B,
8 | | }
| |_^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: failed to parse path: "~~~"
|
12 | #[serde(getter = "~~~")]
| ^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: failed to parse path: "~~~"
|
10 | #[serde(remote = "~~~")]
| ^^^^^
error: aborting due to previous error

View File

@ -9,6 +9,3 @@ error: #[serde(getter = "...")] is not allowed in an enum
15 | | },
16 | | }
| |_^
error: aborting due to previous error

View File

@ -4,6 +4,4 @@ error[E0063]: missing field `b` in initializer of `remote::S`
11 | #[serde(remote = "remote::S")]
| ^^^^^^^^^^^ missing `b`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0063`.

View File

@ -6,6 +6,3 @@ error: #[serde(getter = "...")] can only be used in structs that have #[serde(re
6 | | a: u8,
7 | | }
| |_^
error: aborting due to previous error

View File

@ -10,7 +10,5 @@ error[E0560]: struct `remote::S` has no field named `b`
12 | b: u8,
| ^ help: a field with a similar name exists: `a`
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0560, E0609.
For more information about an error, try `rustc --explain E0560`.

View File

@ -3,11 +3,5 @@ error[E0308]: mismatched types
|
7 | #[derive(Deserialize)]
| ^^^^^^^^^^^ expected u16, found u8
help: you can cast an `u8` to `u16`, which will zero-extend the source value
|
7 | #[derive(Deserialize.into())]
| ^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View File

@ -7,6 +7,4 @@ error[E0308]: mismatched types
= note: expected type `&u8`
found type `&u16`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View File

@ -7,6 +7,4 @@ error[E0308]: mismatched types
= note: expected type `&u8`
found type `&u16`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View File

@ -3,6 +3,3 @@ error: unknown rename rule for #[serde(rename_all = "abc")]
|
4 | #[serde(rename_all = "abc")]
| ^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: unknown rename rule for #[serde(rename_all = "abc")]
|
5 | #[serde(rename_all = "abc")]
| ^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: #[serde(tag = "...")] can only be used on enums and structs with named fi
|
5 | struct S(u8, u8);
| ^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: #[serde(tag = "...")] can only be used on enums and structs with named fi
|
3 | #[derive(Serialize)]
| ^^^^^^^^^
error: aborting due to previous error

View File

@ -7,6 +7,3 @@ error: #[serde(transparent)] requires struct to have at most one transparent fie
7 | | b: u8,
8 | | }
| |_^
error: aborting due to previous error

View File

@ -9,6 +9,3 @@ error: #[serde(transparent)] requires at least one field that is neither skipped
9 | | b: u8,
10 | | }
| |_^
error: aborting due to previous error

View File

@ -4,6 +4,3 @@ error: #[serde(transparent)] is not allowed on an enum
4 | / #[serde(transparent)]
5 | | enum E {}
| |_________^
error: aborting due to previous error

View File

@ -7,6 +7,3 @@ error: #[serde(transparent)] requires at least one field that is not skipped
7 | | a: u8,
8 | | }
| |_^
error: aborting due to previous error

View File

@ -4,6 +4,3 @@ error: #[serde(transparent)] is not allowed on a unit struct
4 | / #[serde(transparent)]
5 | | struct S;
| |_________^
error: aborting due to previous error

View File

@ -6,6 +6,3 @@ error: #[serde(transparent)] is not allowed with #[serde(from = "...")]
6 | | a: u8,
7 | | }
| |_^
error: aborting due to previous error

View File

@ -6,6 +6,3 @@ error: #[serde(transparent)] is not allowed with #[serde(into = "...")]
6 | | a: u8,
7 | | }
| |_^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: failed to parse type: from = "Option<T"
|
4 | #[serde(from = "Option<T")]
| ^^^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: failed to parse type: into = "Option<T"
|
4 | #[serde(into = "Option<T")]
| ^^^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: unexpected literal in serde container attribute
|
4 | #[serde("literal")]
| ^^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: unexpected literal in serde field attribute
|
5 | #[serde("literal")]
| ^^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: unexpected literal in serde variant attribute
|
5 | #[serde("literal")]
| ^^^^^^^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: unknown serde container attribute `abc`
|
4 | #[serde(abc = "xyz")]
| ^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: unknown serde field attribute `abc`
|
5 | #[serde(abc = "xyz")]
| ^^^
error: aborting due to previous error

View File

@ -3,6 +3,3 @@ error: unknown serde variant attribute `abc`
|
5 | #[serde(abc = "xyz")]
| ^^^
error: aborting due to previous error

View File

@ -6,6 +6,3 @@ error: Serde does not support derive for unions
6 | | y: (),
7 | | }
| |_^
error: aborting due to previous error

View File

@ -6,6 +6,3 @@ error: Serde does not support derive for unions
6 | | y: (),
7 | | }
| |_^
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

View File

@ -4,6 +4,3 @@ error: variant `Newtype` cannot have both #[serde(deserialize_with)] and a field
5 | / #[serde(deserialize_with = "deserialize_some_newtype_variant")]
6 | | Newtype(#[serde(skip_deserializing)] String),
| |________________________________________________^
error: aborting due to previous error

View File

@ -8,6 +8,3 @@ error: variant `Struct` cannot have both #[serde(deserialize_with)] and a field
9 | | f2: u8,
10 | | },
| |_____^
error: aborting due to previous error

View File

@ -4,6 +4,3 @@ error: variant `Tuple` cannot have both #[serde(deserialize_with)] and a field #
5 | / #[serde(deserialize_with = "deserialize_some_other_variant")]
6 | | Tuple(#[serde(skip_deserializing)] String, u8),
| |__________________________________________________^
error: aborting due to previous error

View File

@ -5,6 +5,3 @@ error: variant `Unit` cannot have both #[serde(deserialize_with)] and #[serde(sk
6 | | #[serde(skip_deserializing)]
7 | | Unit,
| |________^
error: aborting due to previous error

View File

@ -4,6 +4,3 @@ error: variant `Newtype` cannot have both #[serde(serialize_with)] and a field #
5 | / #[serde(serialize_with = "serialize_some_newtype_variant")]
6 | | Newtype(#[serde(skip_serializing)] String),
| |______________________________________________^
error: aborting due to previous error

View File

@ -4,6 +4,3 @@ error: variant `Newtype` cannot have both #[serde(serialize_with)] and a field #
5 | / #[serde(serialize_with = "serialize_some_newtype_variant")]
6 | | Newtype(#[serde(skip_serializing_if = "always")] String),
| |____________________________________________________________^
error: aborting due to previous error

View File

@ -8,6 +8,3 @@ error: variant `Struct` cannot have both #[serde(serialize_with)] and a field `f
9 | | f2: u8,
10 | | },
| |_____^
error: aborting due to previous error

View File

@ -8,6 +8,3 @@ error: variant `Struct` cannot have both #[serde(serialize_with)] and a field `f
9 | | f2: u8,
10 | | },
| |_____^
error: aborting due to previous error

View File

@ -4,6 +4,3 @@ error: variant `Tuple` cannot have both #[serde(serialize_with)] and a field #0
5 | / #[serde(serialize_with = "serialize_some_other_variant")]
6 | | Tuple(#[serde(skip_serializing)] String, u8),
| |________________________________________________^
error: aborting due to previous error

View File

@ -4,6 +4,3 @@ error: variant `Tuple` cannot have both #[serde(serialize_with)] and a field #0
5 | / #[serde(serialize_with = "serialize_some_other_variant")]
6 | | Tuple(#[serde(skip_serializing_if = "always")] String, u8),
| |______________________________________________________________^
error: aborting due to previous error

View File

@ -5,6 +5,3 @@ error: variant `Unit` cannot have both #[serde(serialize_with)] and #[serde(skip
6 | | #[serde(skip_serializing)]
7 | | Unit,
| |________^
error: aborting due to previous error