Skip to content

Commit

Permalink
CI: replace compiletest with trybuild
Browse files Browse the repository at this point in the history
in the same vein as rtic-rs/rtic#268
  • Loading branch information
japaric committed Nov 7, 2019
1 parent e9607a7 commit 4b31d6d
Show file tree
Hide file tree
Showing 57 changed files with 7 additions and 185 deletions.
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ matrix:
- env: TARGET=x86_64-unknown-linux-gnu
rust: stable

# compile-fail tests
- env: TARGET=x86_64-unknown-linux-gnu
# TODO revert to nightly when rustc bug is fixed
rust: nightly-2019-07-10

before_install: set -e

script:
Expand Down
9 changes: 1 addition & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ name = "rtfm-syntax"
repository = "https://github.com/rtfm-rs/rtfm-syntax"
version = "0.4.0-beta.2"

[[test]]
name = "ui"
required-features = ["compiletest_rs"]

[dependencies]
indexmap = "1.0.2"
proc-macro2 = "1"
Expand All @@ -28,10 +24,7 @@ version = "1"
[dev-dependencies]
mock = { path = "mock" }
quote = "1"

[dependencies.compiletest_rs]
optional = true
version = "0.3.22"
trybuild = "1"

[workspace]
members = [
Expand Down
3 changes: 2 additions & 1 deletion ci/script.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
set -euxo pipefail

main() {
if [ $TRAVIS_RUST_VERSION = nightly ]; then
if [ $TRAVIS_RUST_VERSION == 1.*.* ]; then
# test on a fixed version (MSRV) to avoid problems with changes in rustc diagnostics
cargo test --features compiletest_rs --test ui
else
cargo test --lib --examples
Expand Down
16 changes: 4 additions & 12 deletions tests/ui.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
use std::path::PathBuf;

use compiletest_rs::{common::Mode, Config};
use trybuild::TestCases;

#[test]
fn ui() {
let mut config = Config::default();

config.mode = Mode::Ui;
config.src_base = PathBuf::from("ui");
config.target_rustcflags = Some("--edition=2018 -Z unstable-options --extern mock".to_owned());
config.link_deps();
config.clean_rmeta();

compiletest_rs::run_tests(&config);
let t = TestCases::new();
t.compile_fail("ui/single/*.rs");
t.compile_fail("ui/multi/*.rs");
}
3 changes: 0 additions & 3 deletions ui/multi/extern-interrupt-no-core.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: core needs to be specified using the `#[core = 0]` attribute
|
6 | fn foo();
| ^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/multi/idle-no-core.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: all `#[idle]` functions must specify the core they'll run on
|
6 | fn idle(_: idle::Context) -> ! {
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/multi/init-late-is-not.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this is not a late resource
|
11 | #[init(core = 0, late = [b])]
| ^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/multi/init-late-resources-extra.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: no more late resources to initialize; this function must NOT return `Late
|
13 | fn init(_: init::Context) -> init::LateResources {}
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/multi/init-late-resources-split.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: unclear how initialization of late resources is split between cores 0 and
|
13 | fn init(_: init::Context) -> init::LateResources {}
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/multi/init-late-twice.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this resource is initialized by core 0
|
13 | #[init(core = 1, late = [a])]
| ^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/multi/init-late-uninitialized.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this resource is not being initialized
|
8 | c: u32,
| ^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/multi/init-late-wrong-signature.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: the `late` argument can only be used on functions that return `LateResour
|
10 | fn init(_: init::Context) {}
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/multi/init-no-core.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: all `#[init]` functions must specify the core they'll run on
|
6 | fn init(_: init::Context) {}
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/multi/interrupt-double.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: a task has already been bound to this interrupt on this core
|
8 | #[task(core = 0, binds = UART0)]
| ^^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/multi/resource-cross.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: resources can NOT be exclusively accessed (`&mut-`) from different cores
|
12 | #[task(core = 1, resources = [x])]
| ^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/multi/task-no-core.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this task must be assigned to a core
|
6 | fn foo(_: foo::Context) {}
| ^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/extern-interrupt-used.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: `extern` interrupts can't be used as hardware tasks
|
5 | #[task(binds = EXTI0)]
| ^^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/idle-double-resources.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: argument appears more than once
|
5 | #[idle(resources = [A], resources = [B])]
| ^^^^^^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/idle-double-spawn.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: argument appears more than once
|
5 | #[idle(spawn = [foo], spawn = [bar])]
| ^^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/idle-input.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this `#[idle]` function must have signature `fn(idle::Context) -> !`
|
6 | fn idle(_: idle::Context, _undef: u32) -> ! {
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/idle-no-context.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this `#[idle]` function must have signature `fn(idle::Context) -> !`
|
6 | fn idle() -> ! {
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/idle-not-divergent.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this `#[idle]` function must have signature `fn(idle::Context) -> !`
|
6 | fn idle(_: idle::Context) {}
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/idle-output.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this `#[idle]` function must have signature `fn(idle::Context) -> !`
|
6 | fn idle(_: idle::Context) -> u32 {
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/idle-pub.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this `#[idle]` function must have signature `fn(idle::Context) -> !`
|
6 | pub fn idle(_: idle::Context) -> ! {
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/idle-unsafe.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this `#[idle]` function must have signature `fn(idle::Context) -> !`
|
6 | unsafe fn idle(_: idle::Context) -> ! {
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/init-divergent.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this `#[init]` function must have signature `fn(init::Context) [-> init::
|
6 | fn init(_: init::Context) -> ! {
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/init-double-resources.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: argument appears more than once
|
5 | #[init(resources = [A], resources = [B])]
| ^^^^^^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/init-double-spawn.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: argument appears more than once
|
5 | #[init(spawn = [foo], spawn = [bar])]
| ^^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/init-extra-late-resources.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: no late resources exist so this function must NOT return `LateResources`
|
6 | fn init(_: init::Context) -> init::LateResources {}
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/init-input.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this `#[init]` function must have signature `fn(init::Context) [-> init::
|
6 | fn init(_: init::Context, _undef: u32) {}
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/init-no-context.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this `#[init]` function must have signature `fn(init::Context) [-> init::
|
6 | fn init() {}
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/init-no-late-resources.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: late resources exist so `#[init]` must return `init::LateResources`
|
10 | fn init(_: init::Context) {}
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/init-output.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this `#[init]` function must have signature `fn(init::Context) [-> init::
|
6 | fn init(_: init::Context) -> u32 {
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/init-pub.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this `#[init]` function must have signature `fn(init::Context) [-> init::
|
6 | pub fn init(_: init::Context) {}
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/init-resources-late.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: late resources can NOT be assigned to `init`
|
9 | #[init(resources = [x])]
| ^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/init-shared-access.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: `init` has direct exclusive access to resources; use `x` instead of `&x`
|
10 | #[init(resources = [&x])]
| ^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/init-unsafe.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this `#[init]` function must have signature `fn(init::Context) [-> init::
|
6 | unsafe fn init(_: init::Context) {}
| ^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/interrupt-double.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: a task has already been bound to this interrupt
|
8 | #[task(binds = UART0)]
| ^^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/local-shared.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: `#[shared]` can only be used in multi-core mode
|
7 | #[shared]
| ^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/resource-not-declared.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this resource has NOT been declared
|
5 | #[task(resources = [A])]
| ^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/resource-pub.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this field must have inherited / private visibility
|
7 | pub x: u32,
| ^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/resource-shared.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: `#[shared]` can only be used in multi-core mode
|
6 | #[shared]
| ^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/task-divergent.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this task handler must have type signature `fn(foo::Context, ..)`
|
6 | fn foo(_: foo::Context) -> ! {
| ^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/task-double-capacity.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: argument appears more than once
|
5 | #[task(capacity = 1, capacity = 2)]
| ^^^^^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/task-double-priority.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: argument appears more than once
|
5 | #[task(priority = 1, priority = 2)]
| ^^^^^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/task-double-resources.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: argument appears more than once
|
5 | #[task(resources = [A], resources = [B])]
| ^^^^^^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/task-double-spawn.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: argument appears more than once
|
5 | #[task(spawn = [bar], spawn = [baz])]
| ^^^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/task-idle.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this identifier has already been used
|
12 | fn foo(_: foo::Context) {}
| ^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/task-init.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this identifier has already been used
|
10 | fn foo(_: foo::Context) {}
| ^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/task-interrupt.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this task is defined multiple times
|
9 | fn foo(_: foo::Context) {}
| ^^^

error: aborting due to previous error

3 changes: 0 additions & 3 deletions ui/single/task-no-context.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: this task handler must have type signature `fn(foo::Context, ..)`
|
6 | fn foo() {}
| ^^^

error: aborting due to previous error

0 comments on commit 4b31d6d

Please sign in to comment.