Skip to content

Commit 274df75

Browse files
committed
Isolate try-build tests from riscv-rt
1 parent 5e211cd commit 274df75

33 files changed

+85
-67
lines changed

.github/workflows/riscv-rt.yaml

+17-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
name: Build check (riscv-rt)
88

99
jobs:
10-
build:
10+
build-riscv:
1111
strategy:
1212
matrix:
1313
# All generated code should be running on stable now, MRSV is 1.61.0
@@ -43,11 +43,25 @@ jobs:
4343
run: RUSTFLAGS="-C link-arg=-Triscv-rt/examples/device.x" cargo build --package riscv-rt --target ${{ matrix.target }} --example ${{ matrix.example }} --features=v-trap
4444
- name: Build (all features)
4545
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
46-
46+
47+
build-others:
48+
strategy:
49+
matrix:
50+
os: [ macos-latest, ubuntu-latest, windows-latest ]
51+
runs-on: ${{ matrix.os }}
52+
steps:
53+
- uses: actions/checkout@v4
54+
- uses: dtolnay/rust-toolchain@stable
55+
- name: Build (no features)
56+
run: cargo build --package riscv-rt
57+
- name: Build (all features)
58+
run: cargo build --package riscv-rt --all-features
59+
4760
# Job to check that all the builds succeeded
4861
build-check:
4962
needs:
50-
- build
63+
- build-riscv
64+
- build-others
5165
runs-on: ubuntu-latest
5266
if: always()
5367
steps:

.github/workflows/tests.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
on:
2+
push:
3+
branches: [ master ]
4+
pull_request:
5+
merge_group:
6+
7+
name: Run macro tests (tests)
8+
9+
jobs:
10+
run-tests:
11+
strategy:
12+
matrix:
13+
os: [ macos-latest, ubuntu-latest ] # windows shows weird linking errors
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: dtolnay/rust-toolchain@nightly
18+
- name: Run tests
19+
run: cargo test --package tests
20+
21+
# Job to check that all the builds succeeded
22+
tests-check:
23+
needs:
24+
- run-tests
25+
runs-on: ubuntu-latest
26+
if: always()
27+
steps:
28+
- run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ members = [
66
"riscv-peripheral",
77
"riscv-rt",
88
"riscv-semihosting",
9+
"tests",
910
]

riscv-rt/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ riscv-pac = { path = "../riscv-pac", version = "0.2.0" }
2525
riscv-rt-macros = { path = "macros", version = "0.2.1" }
2626

2727
[dev-dependencies]
28-
trybuild = "1.0"
2928
panic-halt = "0.2.0"
3029

3130
[features]

riscv-rt/examples/empty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#![no_main]
33

44
extern crate panic_halt;
5-
extern crate riscv_rt;
65

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

riscv-rt/examples/multi_core.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#![no_main]
33

44
extern crate panic_halt;
5-
extern crate riscv;
6-
extern crate riscv_rt;
75

86
use riscv::asm::wfi;
97
use riscv::register::{mie, mip};

riscv-rt/macros/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#![deny(warnings)]
22

3+
extern crate core;
4+
extern crate proc_macro;
5+
extern crate proc_macro2;
6+
extern crate quote;
7+
extern crate syn;
8+
39
use proc_macro2::{Span, TokenStream as TokenStream2};
410
use quote::quote;
511
use syn::{

riscv-rt/tests/test.rs

-6
This file was deleted.

riscv-rt/tests/ui/external_interrupt/fail_arguments.rs

-31
This file was deleted.

riscv-rt/tests/ui/external_interrupt/fail_arguments.stderr

-5
This file was deleted.

tests/Cargo.toml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "tests"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
riscv = { path = "../riscv", version = "0.12.0" }
8+
riscv-rt = { path = "../riscv-rt", version = "0.13.0" }
9+
trybuild = "1.0"

riscv-rt/tests/ui/core_interrupt/fail_empty_macro.stderr renamed to tests/tests/riscv-rt/core_interrupt/fail_empty_macro.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `#[core_interrupt]` attribute expects a path to a variant of an enum that implements the riscv_rt :: CoreInterruptNumber trait.
2-
--> tests/ui/core_interrupt/fail_empty_macro.rs:1:1
2+
--> tests/riscv-rt/core_interrupt/fail_empty_macro.rs:1:1
33
|
44
1 | #[riscv_rt::core_interrupt]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

riscv-rt/tests/ui/core_interrupt/fail_impl_interrupt_number.stderr renamed to tests/tests/riscv-rt/core_interrupt/fail_impl_interrupt_number.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the trait bound `riscv::interrupt::Exception: CoreInterruptNumber` is not satisfied
2-
--> tests/ui/core_interrupt/fail_impl_interrupt_number.rs:1:28
2+
--> tests/riscv-rt/core_interrupt/fail_impl_interrupt_number.rs:1:28
33
|
44
1 | #[riscv_rt::core_interrupt(riscv::interrupt::Exception::LoadMisaligned)]
55
| ---------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--
@@ -11,7 +11,7 @@ error[E0277]: the trait bound `riscv::interrupt::Exception: CoreInterruptNumber`
1111
riscv::interrupt::Interrupt
1212
riscv::interrupt::supervisor::Interrupt
1313
note: required by a bound in `assert_impl`
14-
--> tests/ui/core_interrupt/fail_impl_interrupt_number.rs:1:1
14+
--> tests/riscv-rt/core_interrupt/fail_impl_interrupt_number.rs:1:1
1515
|
1616
1 | #[riscv_rt::core_interrupt(riscv::interrupt::Exception::LoadMisaligned)]
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl`
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error: `#[core_interrupt]` function must have signature `[unsafe] fn() [-> !]`
2-
--> tests/ui/core_interrupt/fail_signatures.rs:2:1
2+
--> tests/riscv-rt/core_interrupt/fail_signatures.rs:2:1
33
|
44
2 | fn my_interrupt(code: usize) {}
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

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

1313
error: `#[core_interrupt]` function must have signature `[unsafe] fn() [-> !]`
14-
--> tests/ui/core_interrupt/fail_signatures.rs:8:1
14+
--> tests/riscv-rt/core_interrupt/fail_signatures.rs:8:1
1515
|
1616
8 | async fn my_async_interrupt() {}
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

riscv-rt/tests/ui/exception/fail_empty_macro.stderr renamed to tests/tests/riscv-rt/exception/fail_empty_macro.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `#[exception]` attribute expects a path to a variant of an enum that implements the riscv_rt :: ExceptionNumber trait.
2-
--> tests/ui/exception/fail_empty_macro.rs:1:1
2+
--> tests/riscv-rt/exception/fail_empty_macro.rs:1:1
33
|
44
1 | #[riscv_rt::exception]
55
| ^^^^^^^^^^^^^^^^^^^^^^

riscv-rt/tests/ui/exception/fail_impl_exception_number.stderr renamed to tests/tests/riscv-rt/exception/fail_impl_exception_number.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the trait bound `riscv::interrupt::Interrupt: ExceptionNumber` is not satisfied
2-
--> tests/ui/exception/fail_impl_exception_number.rs:1:23
2+
--> tests/riscv-rt/exception/fail_impl_exception_number.rs:1:23
33
|
44
1 | #[riscv_rt::exception(riscv::interrupt::Interrupt::SupervisorSoft)]
55
| ----------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--
@@ -11,7 +11,7 @@ error[E0277]: the trait bound `riscv::interrupt::Interrupt: ExceptionNumber` is
1111
riscv::interrupt::Exception
1212
riscv::interrupt::supervisor::Exception
1313
note: required by a bound in `assert_impl`
14-
--> tests/ui/exception/fail_impl_exception_number.rs:1:1
14+
--> tests/riscv-rt/exception/fail_impl_exception_number.rs:1:1
1515
|
1616
1 | #[riscv_rt::exception(riscv::interrupt::Interrupt::SupervisorSoft)]
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl`
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error: `#[exception]` function must have signature `[unsafe] fn([&[mut] riscv_rt::TrapFrame]) [-> !]`
2-
--> tests/ui/exception/fail_signatures.rs:2:1
2+
--> tests/riscv-rt/exception/fail_signatures.rs:2:1
33
|
44
2 | fn my_exception(code: usize) {}
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

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

1313
error: `#[exception]` function must have signature `[unsafe] fn([&[mut] riscv_rt::TrapFrame]) [-> !]`
14-
--> tests/ui/exception/fail_signatures.rs:8:1
14+
--> tests/riscv-rt/exception/fail_signatures.rs:8:1
1515
|
1616
8 | async fn my_async_exception(trap_frame: &riscv_rt::TrapFrame, code: usize) {}
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

riscv-rt/tests/ui/external_interrupt/fail_empty_macro.stderr renamed to tests/tests/riscv-rt/external_interrupt/fail_empty_macro.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `#[external_interrupt]` attribute expects a path to a variant of an enum that implements the riscv_rt :: ExternalInterruptNumber trait.
2-
--> tests/ui/external_interrupt/fail_empty_macro.rs:1:1
2+
--> tests/riscv-rt/external_interrupt/fail_empty_macro.rs:1:1
33
|
44
1 | #[riscv_rt::external_interrupt]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

riscv-rt/tests/ui/external_interrupt/fail_impl_interrupt_number.stderr renamed to tests/tests/riscv-rt/external_interrupt/fail_impl_interrupt_number.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the trait bound `riscv::interrupt::Interrupt: ExternalInterruptNumber` is not satisfied
2-
--> tests/ui/external_interrupt/fail_impl_interrupt_number.rs:1:32
2+
--> tests/riscv-rt/external_interrupt/fail_impl_interrupt_number.rs:1:32
33
|
44
1 | #[riscv_rt::external_interrupt(riscv::interrupt::Interrupt::SupervisorSoft)]
55
| -------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--
@@ -8,7 +8,7 @@ error[E0277]: the trait bound `riscv::interrupt::Interrupt: ExternalInterruptNum
88
| required by a bound introduced by this call
99
|
1010
note: required by a bound in `assert_impl`
11-
--> tests/ui/external_interrupt/fail_impl_interrupt_number.rs:1:1
11+
--> tests/riscv-rt/external_interrupt/fail_impl_interrupt_number.rs:1:1
1212
|
1313
1 | #[riscv_rt::external_interrupt(riscv::interrupt::Interrupt::SupervisorSoft)]
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl`
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error: `#[external_interrupt]` function must have signature `[unsafe] fn() [-> !]`
2-
--> tests/ui/external_interrupt/fail_signatures.rs:31:1
2+
--> tests/riscv-rt/external_interrupt/fail_signatures.rs:31:1
33
|
44
31 | fn my_interrupt() -> usize {}
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
66

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

1313
error: `#[external_interrupt]` function must have signature `[unsafe] fn() [-> !]`
14-
--> tests/ui/external_interrupt/fail_signatures.rs:37:1
14+
--> tests/riscv-rt/external_interrupt/fail_signatures.rs:37:1
1515
|
1616
37 | async fn my_async_interrupt(code: usize) -> usize {}
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/tests/test.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#[test]
2+
fn riscv_rt() {
3+
let t = trybuild::TestCases::new();
4+
t.compile_fail("tests/riscv-rt/*/fail_*.rs");
5+
t.pass("tests/riscv-rt/*/pass_*.rs");
6+
}

0 commit comments

Comments
 (0)