Skip to content

Commit

Permalink
cfg-guard tests which rely on the serde feature
Browse files Browse the repository at this point in the history
Add CI for --no-default-features to catch this in the future.

Signed-off-by: James McCoy <[email protected]>
  • Loading branch information
jamessan committed Dec 31, 2023
1 parent 78fa4d6 commit 69bd94c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
- uses: actions/checkout@v3
- name: Stable
run: cargo test
- name: Stable (no default features)
run: cargo test -p alacritty_terminal --no-default-features
- name: Oldstable
run: |
rustup default 1.70.0
Expand Down
1 change: 1 addition & 0 deletions alacritty_terminal/src/term/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,7 @@ mod tests {
/// This test is in the term module as opposed to the grid since we want to
/// test this property with a T=Cell.
#[test]
#[cfg(feature = "serde")]
fn grid_serde() {
let grid: Grid<Cell> = Grid::new(24, 80, 0);
let serialized = serde_json::to_string(&grid).expect("ser");
Expand Down
5 changes: 5 additions & 0 deletions alacritty_terminal/tests/ref.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#[cfg(feature = "serde")]
use serde::Deserialize;
#[cfg(feature = "serde")]
use serde_json as json;

use std::fs::{self, File};
Expand All @@ -17,6 +19,7 @@ macro_rules! ref_tests {
($($name:ident)*) => {
$(
#[test]
#[cfg(feature = "serde")]
fn $name() {
let test_dir = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/ref"));
let test_path = test_dir.join(stringify!($name));
Expand Down Expand Up @@ -82,6 +85,7 @@ where
res
}

#[cfg(feature = "serde")]
#[derive(Deserialize, Default)]
struct RefConfig {
history_size: u32,
Expand All @@ -94,6 +98,7 @@ impl EventListener for Mock {
fn send_event(&self, _event: Event) {}
}

#[cfg(feature = "serde")]
fn ref_test(dir: &Path) {
let recording = read_u8(dir.join("alacritty.recording"));
let serialized_size = fs::read_to_string(dir.join("size.json")).unwrap();
Expand Down

0 comments on commit 69bd94c

Please sign in to comment.