Skip to content

Commit

Permalink
Merge pull request #44 from VolumeGraphics/report-fixes
Browse files Browse the repository at this point in the history
Report fixes
  • Loading branch information
TheAdiWijaya committed Dec 15, 2023
2 parents 5c41c43 + 149a620 commit 4873436
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "A flexible rule-based file and folder comparison tool and crate i
repository = "https://github.com/VolumeGraphics/havocompare"
homepage = "https://github.com/VolumeGraphics/havocompare"
documentation = "https://docs.rs/havocompare"
version = "0.5.1"
version = "0.5.2"
edition = "2021"
license = "MIT"
authors = ["Volume Graphics GmbH"]
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ rules:

## Changelog

### 0.5.2
- Preserve white spaces in CSV and PDF report instead of being collapsed by HTML
- Add + and - symbols to the report index
- Display combined file names in report index if the compared file names are different

### 0.5.1
- Fix potential crash in JSON checking

Expand Down
28 changes: 27 additions & 1 deletion src/report/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,19 @@ pub(crate) fn get_relative_path(

paths.reverse();

PathBuf::from_iter(paths)
if paths.is_empty() {
let name = if let (Some(actual), Some(nominal)) = (
actual_path.as_ref().file_name(),
nominal_path.as_ref().file_name(),
) {
format!("{}-{}", actual.to_string_lossy(), nominal.to_string_lossy())
} else {
"unknown".to_owned()
};
PathBuf::from(name)
} else {
PathBuf::from_iter(paths)
}
}

fn log_detail_html_creation_error(e: &Error) -> Option<DetailPath> {
Expand Down Expand Up @@ -996,6 +1008,20 @@ mod tests {
"tests/integ/data/display_of_status_message_in_cm_tables/expected/Volume1.csv",
);
assert_eq!(PathBuf::from("Volume1.csv"), result);

let result = get_relative_path(
"csv/other.csv",
"tests/integ/data/display_of_status_message_in_cm_tables/expected/volume1.csv",
);

assert_eq!(PathBuf::from("other.csv-volume1.csv"), result);

let result = get_relative_path(
"tests/integ/data/display_of_status_message_in_cm_tables/expected/volume1.csv",
"tests/integ/data/display_of_status_message_in_cm_tables/expected/Volume1.csv",
);

assert_eq!(PathBuf::from("volume1.csv-Volume1.csv"), result);
}

#[test]
Expand Down
28 changes: 22 additions & 6 deletions src/report/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ pub const INDEX_TEMPLATE: &str = r##"
color:red;
}
.ui-accordion-header-active:before {
content: '-'
}
.ui-accordion-header-collapsed:before {
content: '+'
}
</style>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.12.1/datatables.min.css"/>
</head>
Expand Down Expand Up @@ -310,6 +318,10 @@ pub const PLAIN_CSV_DETAIL_TEMPLATE: &str = r#"
table.dataTable tbody td, table.dataTable thead th {
padding:0px 0px;
}
.pre-text {
white-space:pre;
}
</style>
</head>
Expand Down Expand Up @@ -366,10 +378,10 @@ pub const PLAIN_CSV_DETAIL_TEMPLATE: &str = r#"
<td data-order="{{ loop.index0 }}">{% if row.has_diff or row.has_error %}&nbsp;<br>{% endif %}{{ loop.index0 }}</td>
{% for col in row.columns %}
<td>
{{ col.nominal_value }}
<span class="pre-text">{{ col.nominal_value }}</span>
{% if row.has_diff or row.has_error %}
<div class="{% if col.diffs|length > 0 %} diffs {% elif col.nominal_value != col.actual_value %} actual {% else %} {% endif %}">
{{ col.actual_value }}
<span class="pre-text">{{ col.actual_value }}</span>
</div>
{% endif %}
</td>
Expand Down Expand Up @@ -456,6 +468,10 @@ pub const PLAIN_PDF_DETAIL_TEMPLATE: &str = r#"
table#compare {
border:1px solid grey;
}
.pre-text {
white-space:pre;
}
</style>
</head>
Expand All @@ -479,14 +495,14 @@ The extracted exact text can be downloaded here: <a href="./{{ nominal_extracted
{% for line in combined_lines %}
<tr>
<td>{{ loop.index }}</td>
<td>{{ line.nominal_value|safe }}</td>
<td><span class="pre-text">{{ line.nominal_value|safe }}</span></td>
<td>
{% if line.diffs|length > 0 %}
<span class="has_error">{{ line.actual_value|safe }}</span>
<span class="pre-text has_error">{{ line.actual_value|safe }}</span>
{% elif line.actual_value != line.nominal_value %}
<span class="has_diff">{{ line.actual_value|safe }}</span>
<span class="pre-text has_diff">{{ line.actual_value|safe }}</span>
{% else %}
{{ line.actual_value|safe }}
<span class="pre-text">{{ line.actual_value|safe }}</span>
{% endif %}
</td>
</tr>
Expand Down

0 comments on commit 4873436

Please sign in to comment.