Skip to content

Commit

Permalink
chore: Move compile-fail tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Techassi committed Sep 30, 2024
1 parent 882d8fa commit ff2fd24
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 92 deletions.
3 changes: 3 additions & 0 deletions crates/stackable-versioned-macros/fixtures/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Snapshot Testing

> [!NOTE]
> Also see the compile-fail tests, described [here](../tests/README.md).
This folder contains fixtures for snapshot testing the `#[versioned()]` macro. Snapshot testing is
done using the [insta] crate. It provides a [CLI tool][insta-cli] called `cargo-insta` and a
[VS Code extension][insta-ext].
Expand Down
17 changes: 17 additions & 0 deletions crates/stackable-versioned-macros/tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Compile-Fail Testing

> [!NOTE]
> Also see the snapshot tests, described [here](../fixtures/README.md).
This type of testing is part of UI testing. These tests assert two things: First, the code should
**not** compile and secondly should also produce the expected rustc (compiler) error message. For
this type of testing, we use the [`trybuild`][trybuild] crate.

Tests are currently separated into two folders: `default` and `k8s`. The default test cases don't
require any additional features to be activated. The Kubernetes specific tests require the `k8s`
feature to be enabled. These tests can be run with `cargo test --all-features`.

Further information about the workflow are described [here][workflow].

[workflow]: https://docs.rs/trybuild/latest/trybuild/#workflow
[trybuild]: https://docs.rs/trybuild/latest/trybuild/

This file was deleted.

23 changes: 0 additions & 23 deletions crates/stackable-versioned-macros/tests/enum.rs

This file was deleted.

53 changes: 0 additions & 53 deletions crates/stackable-versioned-macros/tests/from.rs

This file was deleted.

16 changes: 6 additions & 10 deletions crates/stackable-versioned-macros/tests/trybuild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,26 @@
// again but before running tests, otherwise compilation will fail (as expected).
#[allow(dead_code)]
mod default {
// mod fail {
// mod deprecate;
// mod skip_from_all;
// mod skip_from_version;
// }
// mod deprecate;
// mod skip_from_all;
// mod skip_from_version;
}

#[test]
fn default_macros() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/default/fail/*.rs");
t.compile_fail("tests/default/*.rs");
}

#[cfg(feature = "k8s")]
#[allow(dead_code)]
mod k8s {
// mod fail {
// mod crd;
// }
// mod crd;
}

#[cfg(feature = "k8s")]
#[test]
fn k8s_macros() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/k8s/fail/*.rs");
t.compile_fail("tests/k8s/*.rs");
}

0 comments on commit ff2fd24

Please sign in to comment.