Skip to content

Commit

Permalink
rename snapshot and make tests work cross-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Dec 14, 2023
1 parent a38b2bc commit bacc78b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 20 deletions.
25 changes: 19 additions & 6 deletions src/recipe/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ impl Recipe {
#[cfg(test)]
mod tests {
use insta::assert_yaml_snapshot;
use rattler_conda_types::Platform;

use crate::{assert_miette_snapshot, variant_config::ParseErrors};

Expand All @@ -283,12 +284,24 @@ mod tests {
#[test]
fn it_works() {
let recipe = include_str!("../../examples/xtensor/recipe.yaml");
let recipe = Recipe::from_yaml(recipe, SelectorConfig::default());
assert!(recipe.is_ok());
#[cfg(target_family = "unix")]
insta::assert_debug_snapshot!(recipe.unwrap());
#[cfg(target_family = "windows")]
insta::assert_debug_snapshot!("recipe_windows", recipe.unwrap());

let selector_config_win = SelectorConfig {
target_platform: Platform::Win64,
..SelectorConfig::default()
};

let selector_config_unix = SelectorConfig {
target_platform: Platform::Linux64,
..SelectorConfig::default()
};

let unix_recipe = Recipe::from_yaml(recipe, selector_config_unix);
let win_recipe = Recipe::from_yaml(recipe, selector_config_win);
assert!(unix_recipe.is_ok());
assert!(win_recipe.is_ok());

insta::assert_debug_snapshot!("unix_recipe", unix_recipe.unwrap());
insta::assert_debug_snapshot!("recipe_windows", win_recipe.unwrap());
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: src/recipe/parser.rs
expression: recipe.unwrap()
expression: win_recipe.unwrap()
---
Recipe {
package: Package {
Expand Down Expand Up @@ -254,18 +254,25 @@ Recipe {
from_package: {},
},
},
test: Test {
imports: [],
commands: [
"if not exist %LIBRARY_PREFIX%\\include\\xtensor\\xarray.hpp (exit 1)",
"if not exist %LIBRARY_PREFIX%\\share\\cmake\\xtensor\\xtensorConfig.cmake (exit 1)",
"if not exist %LIBRARY_PREFIX%\\share\\cmake\\xtensor\\xtensorConfigVersion.cmake (exit 1)",
],
requires: [],
source_files: [],
files: [],
package_contents: None,
},
tests: [
Command(
CommandsTest {
script: [
"if not exist %LIBRARY_PREFIX%\\include\\xtensor\\xarray.hpp (exit 1)",
"if not exist %LIBRARY_PREFIX%\\share\\cmake\\xtensor\\xtensorConfig.cmake (exit 1)",
"if not exist %LIBRARY_PREFIX%\\share\\cmake\\xtensor\\xtensorConfigVersion.cmake (exit 1)",
],
requirements: CommandsTestRequirements {
run: [],
build: [],
},
files: CommandsTestFiles {
source: [],
recipe: [],
},
},
),
],
about: About {
homepage: Some(
Url {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: src/recipe/parser.rs
expression: recipe.unwrap()
expression: unix_recipe.unwrap()
---
Recipe {
package: Package {
Expand Down

0 comments on commit bacc78b

Please sign in to comment.