mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 21:55:15 +00:00
Add end-to-end build tests
This commit is contained in:
43
rojo-test/src/lib.rs
Normal file
43
rojo-test/src/lib.rs
Normal 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);
|
||||
}
|
||||
}
|
||||
13
rojo-test/src/snapshots/rojo_test__build_gitkeep.snap
Normal file
13
rojo-test/src/snapshots/rojo_test__build_gitkeep.snap
Normal 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>
|
||||
19
rojo-test/src/snapshots/rojo_test__build_txt_in_folder.snap
Normal file
19
rojo-test/src/snapshots/rojo_test__build_txt_in_folder.snap
Normal 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>
|
||||
Reference in New Issue
Block a user