Add end-to-end build tests

This commit is contained in:
Lucien Greathouse
2019-08-07 17:41:17 -07:00
parent 62bb5a28aa
commit 77db25b4d9
10 changed files with 363 additions and 0 deletions

43
rojo-test/src/lib.rs Normal file
View File

@@ -0,0 +1,43 @@
use std::{
fs,
path::Path,
process::Command,
};
use insta::assert_snapshot_matches;
use tempfile::tempdir;
static BUILD_TESTS: &[&str] = &[
"gitkeep",
"txt_in_folder",
];
#[test]
fn build_tests() {
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
let build_test_path = manifest_dir.join("build-tests");
let working_dir = manifest_dir.parent().unwrap();
let output_dir = tempdir().expect("couldn't create temporary directory");
for &test_name in BUILD_TESTS {
let input_path = build_test_path.join(test_name);
let output_path = output_dir.path().join(format!("{}.rbxmx", test_name));
let status = Command::new("cargo")
.args(&[
"run", "--",
"build", input_path.to_str().unwrap(), "-o", output_path.to_str().unwrap(),
])
.current_dir(working_dir)
.status()
.expect("Couldn't start Rojo");
assert!(status.success(), "Rojo did not exit successfully");
let contents = fs::read_to_string(&output_path)
.expect("Couldn't read output file");
assert_snapshot_matches!(format!("build_{}", test_name), contents);
}
}

View File

@@ -0,0 +1,13 @@
---
created: "2019-08-08T00:40:36.892733600Z"
creator: insta@0.10.0
source: rojo-test/src/lib.rs
expression: contents
---
<roblox version="4">
<Item class="Folder" referent="0">
<Properties>
<string name="Name">gitkeep</string>
</Properties>
</Item>
</roblox>

View File

@@ -0,0 +1,19 @@
---
created: "2019-08-08T00:40:50.026718300Z"
creator: insta@0.10.0
source: rojo-test/src/lib.rs
expression: contents
---
<roblox version="4">
<Item class="Folder" referent="0">
<Properties>
<string name="Name">txt_in_folder</string>
</Properties>
<Item class="StringValue" referent="1">
<Properties>
<string name="Name">foo</string>
<string name="Value"></string>
</Properties>
</Item>
</Item>
</roblox>