generated from tweag/project
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This includes moving the sample tests to Topiary cli (because topiary no longer knows about languages). Additionally, bash was reverted back to an older version due to a regression that needs to be investigated.
- Loading branch information
Erin van der Veen
committed
Jan 3, 2024
1 parent
b2e65ca
commit d81b80b
Showing
25 changed files
with
98 additions
and
152 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
use assert_cmd::Command; | ||
use std::fs; | ||
use std::path::Path; | ||
use topiary::test_utils::pretty_assert_eq; | ||
|
||
use tempfile::TempDir; | ||
|
||
#[test] | ||
fn input_output_tester() { | ||
let input_dir = fs::read_dir("tests/samples/input").unwrap(); | ||
let expected_dir = Path::new("tests/samples/expected"); | ||
|
||
for file in input_dir { | ||
let file = file.unwrap(); | ||
|
||
// Load the known good formated files | ||
let expected_path = expected_dir.join(file.file_name()); | ||
let expected = fs::read_to_string(expected_path).unwrap(); | ||
|
||
let tmp_dir = TempDir::new().unwrap(); | ||
|
||
// Copy the file to a temp dir | ||
let mut input_file = tmp_dir.path().to_path_buf(); | ||
input_file.push(file.path().file_name().unwrap()); | ||
fs::copy(file.path(), &input_file).unwrap(); | ||
|
||
// Run topiary on the input file in the temp dir | ||
let mut topiary = Command::cargo_bin("topiary").unwrap(); | ||
topiary | ||
// .env("TOPIARY_LANGUAGE_DIR", "../queries/") | ||
.arg("fmt") | ||
.arg(&input_file) | ||
.assert() | ||
.success(); | ||
|
||
// Read the file after formatting | ||
let formatted = fs::read_to_string(input_file).unwrap(); | ||
|
||
// Assert the formatted file is as expected | ||
pretty_assert_eq(&expected, &formatted); | ||
} | ||
} | ||
|
||
// Test that our query files are properly formatted | ||
#[test] | ||
fn formatted_query_tester() { | ||
let language_dir = fs::read_dir("../queries").unwrap(); | ||
|
||
for file in language_dir { | ||
let file = file.unwrap(); | ||
|
||
// Load the query file (we assume is formatted correctly) | ||
let expected = fs::read_to_string(file.path()).unwrap(); | ||
|
||
let tmp_dir = TempDir::new().unwrap(); | ||
|
||
// Copy the file to a temp dir | ||
let mut input_file = tmp_dir.path().to_path_buf(); | ||
input_file.push(file.path().file_name().unwrap()); | ||
fs::copy(file.path(), &input_file).unwrap(); | ||
|
||
// Run topiary on the input file in the temp dir | ||
let mut topiary = Command::cargo_bin("topiary").unwrap(); | ||
topiary | ||
// .env("TOPIARY_LANGUAGE_DIR", "../queries/") | ||
.arg("fmt") | ||
.arg(&input_file) | ||
.assert() | ||
.success(); | ||
|
||
// Read the file after formatting | ||
let formatted = fs::read_to_string(input_file).unwrap(); | ||
|
||
pretty_assert_eq(&expected, &formatted); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.