Skip to content

Commit

Permalink
Merge pull request #55 from Manishearth/no-std-tests
Browse files Browse the repository at this point in the history
Move off of #[start] for no_std tests
  • Loading branch information
Manishearth authored Dec 20, 2024
2 parents f43684c + dfa2f85 commit 68bcc2e
Show file tree
Hide file tree
Showing 28 changed files with 186 additions and 486 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ jobs:
toolchain: ${{ matrix.rust }}
override: true
- uses: Swatinem/rust-cache@v1

- name: Downgrade deps for MSRV
run: |
cargo update -p libc --precise 0.2.160
cargo update -p pretty_assertions --precise 1.4.0
- uses: actions-rs/cargo@v1
with:
command: test
Expand Down
29 changes: 6 additions & 23 deletions tests/compile_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,10 @@
#[test]
fn no_std() {
let t = trybuild::TestCases::new();
#[cfg(not(feature = "std"))]
t.compile_fail("tests/no_std/without.rs");
#[cfg(not(feature = "std"))]
t.compile_fail("tests/no_std/multi_line.rs");
#[cfg(not(feature = "std"))]
t.pass("tests/no_std/multi_line_allow.rs");
#[cfg(not(feature = "std"))]
t.compile_fail("tests/no_std/enum_prefix_missing.rs");
#[cfg(not(feature = "std"))]
t.pass("tests/no_std/enum_prefix.rs");
#[cfg(feature = "std")]
t.compile_fail("tests/std/without.rs");
#[cfg(feature = "std")]
t.compile_fail("tests/std/multi_line.rs");
#[cfg(feature = "std")]
t.pass("tests/std/multi_line_allow.rs");
#[cfg(feature = "std")]
t.compile_fail("tests/std/enum_prefix_missing.rs");
#[cfg(feature = "std")]
t.pass("tests/std/enum_prefix.rs");
#[cfg(feature = "std")]
t.pass("tests/std/multiple.rs");
t.pass("tests/no_std/with.rs");
t.compile_fail("tests/ui/without.rs");
t.compile_fail("tests/ui/multi_line.rs");
t.pass("tests/ui/multi_line_allow.rs");
t.compile_fail("tests/ui/enum_prefix_missing.rs");
t.pass("tests/ui/enum_prefix.rs");
t.pass("tests/ui/multiple.rs");
}
44 changes: 44 additions & 0 deletions tests/no_std.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#![no_std]
#![allow(unused)]

// This test ensures that the generated code doesn't reference any stdlib items.

use displaydoc::Display;

#[derive(Display)]
/// Just a basic struct {thing}
struct HappyStruct {
thing: &'static str,
}

#[derive(Display)]
#[ignore_extra_doc_attributes]
/// Just a basic struct {thing}
/// and this line should get ignored
struct HappyStruct2 {
thing: &'static str,
}

#[derive(Display)]
enum Happy {
/// I really like Variant1
Variant1,
/// Variant2 is pretty swell 2
Variant2,
/// Variant3 is okay {sometimes}
Variant3 { sometimes: &'static str },
/**
* Variant4 wants to have a lot of lines
*
* Lets see how this works out for it
*/
Variant4,
/// Variant5 has a parameter {0} and some regular comments
// A regular comment that won't get picked
Variant5(u32),

/// These docs are ignored
#[displaydoc("Variant7 has a parameter {0} and uses #[displaydoc]")]
/// These docs are also ignored
Variant7(u32),
}
36 changes: 0 additions & 36 deletions tests/no_std/enum_prefix.rs

This file was deleted.

35 changes: 0 additions & 35 deletions tests/no_std/enum_prefix_missing.rs

This file was deleted.

22 changes: 0 additions & 22 deletions tests/no_std/enum_prefix_missing.stderr

This file was deleted.

37 changes: 0 additions & 37 deletions tests/no_std/multi_line.rs

This file was deleted.

22 changes: 0 additions & 22 deletions tests/no_std/multi_line.stderr

This file was deleted.

38 changes: 0 additions & 38 deletions tests/no_std/multi_line_allow.rs

This file was deleted.

32 changes: 0 additions & 32 deletions tests/no_std/with.rs

This file was deleted.

28 changes: 0 additions & 28 deletions tests/no_std/without.rs

This file was deleted.

22 changes: 0 additions & 22 deletions tests/no_std/without.stderr

This file was deleted.

Loading

0 comments on commit 68bcc2e

Please sign in to comment.