Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Drop test generator dependency
Browse files Browse the repository at this point in the history
We fold all test cases into a single test case because there doesn't
seem to be a viable alternative.  Not as nice, but we have less
duplicate versions in our tree this way.
  • Loading branch information
swsnr committed Jan 1, 2023
1 parent 469b5fa commit 5000d3d
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 101 deletions.
113 changes: 33 additions & 80 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -42,7 +42,7 @@ terminal_size = "0.2.3"
[dev-dependencies]
pretty_assertions = "1.3.0"
lazy_static = "1.4.0"
test-generator = "0.3.1"
glob = "0.3.0"

[build-dependencies]
# To generate completions during build
Expand Down
44 changes: 24 additions & 20 deletions tests/render.rs
Expand Up @@ -13,15 +13,15 @@

use std::path::Path;

use anyhow::{Context, Result};
use glob::glob;
use lazy_static::lazy_static;
use pretty_assertions::assert_eq;
use pulldown_cmark::{Options, Parser};
use syntect::parsing::SyntaxSet;
use test_generator::test_resources;
use url::Url;

use anyhow::{Context, Result};
use lazy_static::lazy_static;
use mdcat::Environment;
use url::Url;

lazy_static! {
static ref SYNTAX_SET: SyntaxSet = SyntaxSet::load_defaults_newlines();
Expand Down Expand Up @@ -122,7 +122,7 @@ fn test_with_golden_file<S: AsRef<Path>, T: AsRef<Path>>(
})
.unwrap()
.with_extension("");
let expected_file = golden_file_directory.as_ref().join(basename);
let expected_file = golden_file_directory.as_ref().join(&basename);

if std::env::var_os("MDCAT_UPDATE_GOLDEN_FILES").is_some() {
std::fs::write(&expected_file, &actual)
Expand All @@ -137,27 +137,31 @@ fn test_with_golden_file<S: AsRef<Path>, T: AsRef<Path>>(
let expected = std::fs::read_to_string(&expected_file)
.with_context(|| format!("Failed to read golden file at {}", expected_file.display()))
.unwrap();
assert_eq!(actual, expected);
assert_eq!(actual, expected, "Test case: {}", basename.display());
}
}

/// Test basic rendering.
#[test_resources("tests/render/md/*/*.md")]
fn ansi_only(markdown_file: &str) {
test_with_golden_file(
markdown_file,
"tests/render/golden/ansi-only",
&SETTINGS_ANSI_ONLY,
)
#[test]
fn ansi_only() {
for markdown_file in glob("tests/render/md/*/*.md").unwrap() {
test_with_golden_file(
markdown_file.unwrap(),
"tests/render/golden/ansi-only",
&SETTINGS_ANSI_ONLY,
)
}
}

/// Test the full shebang, but not on Windows, since the iTerm2 backend has some unimplemented stuff on Windows.
#[test_resources("tests/render/md/*/*.md")]
#[cfg(not(windows))]
fn iterm2(markdown_file: &str) {
test_with_golden_file(
markdown_file,
"tests/render/golden/iterm2",
&SETTINGS_ITERM2,
)
#[test]
fn iterm2() {
for markdown_file in glob("tests/render/md/*/*.md").unwrap() {
test_with_golden_file(
markdown_file.unwrap(),
"tests/render/golden/iterm2",
&SETTINGS_ITERM2,
)
}
}

0 comments on commit 5000d3d

Please sign in to comment.