Skip to content

Commit 68bcc2e

Browse files
authored
Merge pull request #55 from Manishearth/no-std-tests
Move off of #[start] for no_std tests
2 parents f43684c + dfa2f85 commit 68bcc2e

28 files changed

+186
-486
lines changed

.github/workflows/ci.yml

+5
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ jobs:
7272
toolchain: ${{ matrix.rust }}
7373
override: true
7474
- uses: Swatinem/rust-cache@v1
75+
76+
- name: Downgrade deps for MSRV
77+
run: |
78+
cargo update -p libc --precise 0.2.160
79+
cargo update -p pretty_assertions --precise 1.4.0
7580
- uses: actions-rs/cargo@v1
7681
with:
7782
command: test

tests/compile_tests.rs

+6-23
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,10 @@
33
#[test]
44
fn no_std() {
55
let t = trybuild::TestCases::new();
6-
#[cfg(not(feature = "std"))]
7-
t.compile_fail("tests/no_std/without.rs");
8-
#[cfg(not(feature = "std"))]
9-
t.compile_fail("tests/no_std/multi_line.rs");
10-
#[cfg(not(feature = "std"))]
11-
t.pass("tests/no_std/multi_line_allow.rs");
12-
#[cfg(not(feature = "std"))]
13-
t.compile_fail("tests/no_std/enum_prefix_missing.rs");
14-
#[cfg(not(feature = "std"))]
15-
t.pass("tests/no_std/enum_prefix.rs");
16-
#[cfg(feature = "std")]
17-
t.compile_fail("tests/std/without.rs");
18-
#[cfg(feature = "std")]
19-
t.compile_fail("tests/std/multi_line.rs");
20-
#[cfg(feature = "std")]
21-
t.pass("tests/std/multi_line_allow.rs");
22-
#[cfg(feature = "std")]
23-
t.compile_fail("tests/std/enum_prefix_missing.rs");
24-
#[cfg(feature = "std")]
25-
t.pass("tests/std/enum_prefix.rs");
26-
#[cfg(feature = "std")]
27-
t.pass("tests/std/multiple.rs");
28-
t.pass("tests/no_std/with.rs");
6+
t.compile_fail("tests/ui/without.rs");
7+
t.compile_fail("tests/ui/multi_line.rs");
8+
t.pass("tests/ui/multi_line_allow.rs");
9+
t.compile_fail("tests/ui/enum_prefix_missing.rs");
10+
t.pass("tests/ui/enum_prefix.rs");
11+
t.pass("tests/ui/multiple.rs");
2912
}

tests/no_std.rs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#![no_std]
2+
#![allow(unused)]
3+
4+
// This test ensures that the generated code doesn't reference any stdlib items.
5+
6+
use displaydoc::Display;
7+
8+
#[derive(Display)]
9+
/// Just a basic struct {thing}
10+
struct HappyStruct {
11+
thing: &'static str,
12+
}
13+
14+
#[derive(Display)]
15+
#[ignore_extra_doc_attributes]
16+
/// Just a basic struct {thing}
17+
/// and this line should get ignored
18+
struct HappyStruct2 {
19+
thing: &'static str,
20+
}
21+
22+
#[derive(Display)]
23+
enum Happy {
24+
/// I really like Variant1
25+
Variant1,
26+
/// Variant2 is pretty swell 2
27+
Variant2,
28+
/// Variant3 is okay {sometimes}
29+
Variant3 { sometimes: &'static str },
30+
/**
31+
* Variant4 wants to have a lot of lines
32+
*
33+
* Lets see how this works out for it
34+
*/
35+
Variant4,
36+
/// Variant5 has a parameter {0} and some regular comments
37+
// A regular comment that won't get picked
38+
Variant5(u32),
39+
40+
/// These docs are ignored
41+
#[displaydoc("Variant7 has a parameter {0} and uses #[displaydoc]")]
42+
/// These docs are also ignored
43+
Variant7(u32),
44+
}

tests/no_std/enum_prefix.rs

-36
This file was deleted.

tests/no_std/enum_prefix_missing.rs

-35
This file was deleted.

tests/no_std/enum_prefix_missing.stderr

-22
This file was deleted.

tests/no_std/multi_line.rs

-37
This file was deleted.

tests/no_std/multi_line.stderr

-22
This file was deleted.

tests/no_std/multi_line_allow.rs

-38
This file was deleted.

tests/no_std/with.rs

-32
This file was deleted.

tests/no_std/without.rs

-28
This file was deleted.

tests/no_std/without.stderr

-22
This file was deleted.

0 commit comments

Comments
 (0)