Skip to content

Commit

Permalink
quote and escape test file paths to fix issue with windows paths (#573)
Browse files Browse the repository at this point in the history
* quote and escape test file paths to fix issue with windows paths

* remove explicit quotations from temp file command line arguments in tests
  • Loading branch information
erratic-pattern authored Oct 22, 2023
1 parent d3af02e commit 3c597bb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion tests/harness/src/data/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ use tempfile::NamedTempFile;
/// Display implementation prints the file path as a string, making it easy to reference the file path
/// in CLI tests.
#[derive(Debug, Display)]
#[display(fmt = "{}", "temp_file.path().display()")]
#[display(
fmt = "{}",
"shlex::quote(temp_file.path().to_string_lossy().as_ref())"
)]
pub struct TestFile {
temp_file: NamedTempFile,
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_audit_logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn test_audit_logs() {

/* Create test template */
let temp_file = TestFile::with_contents("# this template has just fixed text").unwrap();
cloudtruth!("template set my-audit-template -b '{temp_file}'")
cloudtruth!("template set my-audit-template -b {temp_file}")
.envs(&env_map)
.assert()
.success();
Expand Down
2 changes: 1 addition & 1 deletion tests/test_templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn test_templates_basic() {

// Create template
cloudtruth!(
"--project {proj} templates set {temp_name} --desc 'Description on create' --body '{temp_file}' "
"--project {proj} templates set {temp_name} --desc 'Description on create' --body {temp_file} "
)
.assert()
.success()
Expand Down

0 comments on commit 3c597bb

Please sign in to comment.