Skip to content

Commit

Permalink
Isolate try-build tests from riscv-rt
Browse files Browse the repository at this point in the history
  • Loading branch information
romancardenas committed Aug 13, 2024
1 parent 5e211cd commit 274df75
Show file tree
Hide file tree
Showing 33 changed files with 85 additions and 67 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/riscv-rt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
name: Build check (riscv-rt)

jobs:
build:
build-riscv:
strategy:
matrix:
# All generated code should be running on stable now, MRSV is 1.61.0
Expand Down Expand Up @@ -43,11 +43,25 @@ jobs:
run: RUSTFLAGS="-C link-arg=-Triscv-rt/examples/device.x" cargo build --package riscv-rt --target ${{ matrix.target }} --example ${{ matrix.example }} --features=v-trap
- name: Build (all features)
run: RUSTFLAGS="-C link-arg=-Triscv-rt/examples/device.x" cargo build --package riscv-rt --target ${{ matrix.target }} --example ${{ matrix.example }} --features=s-mode,single-hart,v-trap


build-others:
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Build (no features)
run: cargo build --package riscv-rt
- name: Build (all features)
run: cargo build --package riscv-rt --all-features

# Job to check that all the builds succeeded
build-check:
needs:
- build
- build-riscv
- build-others
runs-on: ubuntu-latest
if: always()
steps:
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
on:
push:
branches: [ master ]
pull_request:
merge_group:

name: Run macro tests (tests)

jobs:
run-tests:
strategy:
matrix:
os: [ macos-latest, ubuntu-latest ] # windows shows weird linking errors
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Run tests
run: cargo test --package tests

# Job to check that all the builds succeeded
tests-check:
needs:
- run-tests
runs-on: ubuntu-latest
if: always()
steps:
- run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ members = [
"riscv-peripheral",
"riscv-rt",
"riscv-semihosting",
"tests",
]
1 change: 0 additions & 1 deletion riscv-rt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ riscv-pac = { path = "../riscv-pac", version = "0.2.0" }
riscv-rt-macros = { path = "macros", version = "0.2.1" }

[dev-dependencies]
trybuild = "1.0"
panic-halt = "0.2.0"

[features]
Expand Down
1 change: 0 additions & 1 deletion riscv-rt/examples/empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#![no_main]

extern crate panic_halt;
extern crate riscv_rt;

use riscv_rt::{core_interrupt, entry, exception, external_interrupt};

Expand Down
2 changes: 0 additions & 2 deletions riscv-rt/examples/multi_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#![no_main]

extern crate panic_halt;
extern crate riscv;
extern crate riscv_rt;

use riscv::asm::wfi;
use riscv::register::{mie, mip};
Expand Down
6 changes: 6 additions & 0 deletions riscv-rt/macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#![deny(warnings)]

extern crate core;
extern crate proc_macro;
extern crate proc_macro2;
extern crate quote;
extern crate syn;

use proc_macro2::{Span, TokenStream as TokenStream2};
use quote::quote;
use syn::{
Expand Down
6 changes: 0 additions & 6 deletions riscv-rt/tests/test.rs

This file was deleted.

31 changes: 0 additions & 31 deletions riscv-rt/tests/ui/external_interrupt/fail_arguments.rs

This file was deleted.

5 changes: 0 additions & 5 deletions riscv-rt/tests/ui/external_interrupt/fail_arguments.stderr

This file was deleted.

9 changes: 9 additions & 0 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "tests"
version = "0.1.0"
edition = "2021"

[dependencies]
riscv = { path = "../riscv", version = "0.12.0" }
riscv-rt = { path = "../riscv-rt", version = "0.13.0" }
trybuild = "1.0"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `#[core_interrupt]` attribute expects a path to a variant of an enum that implements the riscv_rt :: CoreInterruptNumber trait.
--> tests/ui/core_interrupt/fail_empty_macro.rs:1:1
--> tests/riscv-rt/core_interrupt/fail_empty_macro.rs:1:1
|
1 | #[riscv_rt::core_interrupt]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0277]: the trait bound `riscv::interrupt::Exception: CoreInterruptNumber` is not satisfied
--> tests/ui/core_interrupt/fail_impl_interrupt_number.rs:1:28
--> tests/riscv-rt/core_interrupt/fail_impl_interrupt_number.rs:1:28
|
1 | #[riscv_rt::core_interrupt(riscv::interrupt::Exception::LoadMisaligned)]
| ---------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--
Expand All @@ -11,7 +11,7 @@ error[E0277]: the trait bound `riscv::interrupt::Exception: CoreInterruptNumber`
riscv::interrupt::Interrupt
riscv::interrupt::supervisor::Interrupt
note: required by a bound in `assert_impl`
--> tests/ui/core_interrupt/fail_impl_interrupt_number.rs:1:1
--> tests/riscv-rt/core_interrupt/fail_impl_interrupt_number.rs:1:1
|
1 | #[riscv_rt::core_interrupt(riscv::interrupt::Exception::LoadMisaligned)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: `#[core_interrupt]` function must have signature `[unsafe] fn() [-> !]`
--> tests/ui/core_interrupt/fail_signatures.rs:2:1
--> tests/riscv-rt/core_interrupt/fail_signatures.rs:2:1
|
2 | fn my_interrupt(code: usize) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: `#[core_interrupt]` function must have signature `[unsafe] fn() [-> !]`
--> tests/ui/core_interrupt/fail_signatures.rs:5:1
--> tests/riscv-rt/core_interrupt/fail_signatures.rs:5:1
|
5 | fn my_other_interrupt() -> usize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: `#[core_interrupt]` function must have signature `[unsafe] fn() [-> !]`
--> tests/ui/core_interrupt/fail_signatures.rs:8:1
--> tests/riscv-rt/core_interrupt/fail_signatures.rs:8:1
|
8 | async fn my_async_interrupt() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `#[exception]` attribute expects a path to a variant of an enum that implements the riscv_rt :: ExceptionNumber trait.
--> tests/ui/exception/fail_empty_macro.rs:1:1
--> tests/riscv-rt/exception/fail_empty_macro.rs:1:1
|
1 | #[riscv_rt::exception]
| ^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0277]: the trait bound `riscv::interrupt::Interrupt: ExceptionNumber` is not satisfied
--> tests/ui/exception/fail_impl_exception_number.rs:1:23
--> tests/riscv-rt/exception/fail_impl_exception_number.rs:1:23
|
1 | #[riscv_rt::exception(riscv::interrupt::Interrupt::SupervisorSoft)]
| ----------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--
Expand All @@ -11,7 +11,7 @@ error[E0277]: the trait bound `riscv::interrupt::Interrupt: ExceptionNumber` is
riscv::interrupt::Exception
riscv::interrupt::supervisor::Exception
note: required by a bound in `assert_impl`
--> tests/ui/exception/fail_impl_exception_number.rs:1:1
--> tests/riscv-rt/exception/fail_impl_exception_number.rs:1:1
|
1 | #[riscv_rt::exception(riscv::interrupt::Interrupt::SupervisorSoft)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: `#[exception]` function must have signature `[unsafe] fn([&[mut] riscv_rt::TrapFrame]) [-> !]`
--> tests/ui/exception/fail_signatures.rs:2:1
--> tests/riscv-rt/exception/fail_signatures.rs:2:1
|
2 | fn my_exception(code: usize) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: `#[exception]` function must have signature `[unsafe] fn([&[mut] riscv_rt::TrapFrame]) [-> !]`
--> tests/ui/exception/fail_signatures.rs:5:1
--> tests/riscv-rt/exception/fail_signatures.rs:5:1
|
5 | fn my_other_exception(trap_frame: &riscv_rt::TrapFrame, code: usize) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: `#[exception]` function must have signature `[unsafe] fn([&[mut] riscv_rt::TrapFrame]) [-> !]`
--> tests/ui/exception/fail_signatures.rs:8:1
--> tests/riscv-rt/exception/fail_signatures.rs:8:1
|
8 | async fn my_async_exception(trap_frame: &riscv_rt::TrapFrame, code: usize) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `#[external_interrupt]` attribute expects a path to a variant of an enum that implements the riscv_rt :: ExternalInterruptNumber trait.
--> tests/ui/external_interrupt/fail_empty_macro.rs:1:1
--> tests/riscv-rt/external_interrupt/fail_empty_macro.rs:1:1
|
1 | #[riscv_rt::external_interrupt]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0277]: the trait bound `riscv::interrupt::Interrupt: ExternalInterruptNumber` is not satisfied
--> tests/ui/external_interrupt/fail_impl_interrupt_number.rs:1:32
--> tests/riscv-rt/external_interrupt/fail_impl_interrupt_number.rs:1:32
|
1 | #[riscv_rt::external_interrupt(riscv::interrupt::Interrupt::SupervisorSoft)]
| -------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--
Expand All @@ -8,7 +8,7 @@ error[E0277]: the trait bound `riscv::interrupt::Interrupt: ExternalInterruptNum
| required by a bound introduced by this call
|
note: required by a bound in `assert_impl`
--> tests/ui/external_interrupt/fail_impl_interrupt_number.rs:1:1
--> tests/riscv-rt/external_interrupt/fail_impl_interrupt_number.rs:1:1
|
1 | #[riscv_rt::external_interrupt(riscv::interrupt::Interrupt::SupervisorSoft)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: `#[external_interrupt]` function must have signature `[unsafe] fn() [-> !]`
--> tests/ui/external_interrupt/fail_signatures.rs:31:1
--> tests/riscv-rt/external_interrupt/fail_signatures.rs:31:1
|
31 | fn my_interrupt() -> usize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: `#[external_interrupt]` function must have signature `[unsafe] fn() [-> !]`
--> tests/ui/external_interrupt/fail_signatures.rs:34:1
--> tests/riscv-rt/external_interrupt/fail_signatures.rs:34:1
|
34 | fn my_other_interrupt(code: usize) -> usize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: `#[external_interrupt]` function must have signature `[unsafe] fn() [-> !]`
--> tests/ui/external_interrupt/fail_signatures.rs:37:1
--> tests/riscv-rt/external_interrupt/fail_signatures.rs:37:1
|
37 | async fn my_async_interrupt(code: usize) -> usize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 changes: 6 additions & 0 deletions tests/tests/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[test]
fn riscv_rt() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/riscv-rt/*/fail_*.rs");
t.pass("tests/riscv-rt/*/pass_*.rs");
}

0 comments on commit 274df75

Please sign in to comment.