Skip to content

Commit

Permalink
fix: junit test case name sanitizer (#56)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Chi <iskyzh@gmail.com>
  • Loading branch information
skyzh authored Jul 3, 2022
1 parent d42eae2 commit 6902606
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.5.4] - 2022-07-02

- Remove unsupported characters from juni test name.

## [0.5.3] - 2022-06-26

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sqllogictest"
version = "0.5.3"
version = "0.5.4"
edition = "2021"
description = "Sqllogictest parser and runner."
license = "MIT OR Apache-2.0"
Expand Down
21 changes: 17 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,25 @@ async fn main() -> Result<()> {
let start = Instant::now();

while let Some((file, res, mut buf)) = stream.next().await {
let test_case_name = file
.replace('/', "_")
.replace(' ', "_")
.replace('.', "_")
.replace('-', "_");
let case = match res {
Ok(duration) => {
let mut case = TestCase::new(file, TestCaseStatus::success());
let mut case = TestCase::new(test_case_name, TestCaseStatus::success());
case.set_time(duration);
case
}
Err(e) => {
writeln!(buf, "{}\n\n{:?}", style("[FAILED]").red().bold(), e)?;
writeln!(buf)?;
failed_case.push(file.clone());
TestCase::new(file, TestCaseStatus::non_success(NonSuccessKind::Failure))
TestCase::new(
test_case_name,
TestCaseStatus::non_success(NonSuccessKind::Failure),
)
}
};
test_suite.add_test_case(case);
Expand All @@ -217,9 +225,14 @@ async fn main() -> Result<()> {

for file in files {
let filename = file.to_string_lossy().to_string();
let test_case_name = filename
.replace('/', "_")
.replace(' ', "_")
.replace('.', "_")
.replace('-', "_");
let case = match run_test_file(&mut std::io::stdout(), pg.clone(), &file).await {
Ok(duration) => {
let mut case = TestCase::new(filename, TestCaseStatus::success());
let mut case = TestCase::new(test_case_name, TestCaseStatus::success());
case.set_time(duration);
case
}
Expand All @@ -228,7 +241,7 @@ async fn main() -> Result<()> {
println!();
failed_case.push(filename.clone());
TestCase::new(
filename,
test_case_name,
TestCaseStatus::non_success(NonSuccessKind::Failure),
)
}
Expand Down

0 comments on commit 6902606

Please sign in to comment.