Skip to content

Commit

Permalink
Test for the trailing whitespaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhuighuy committed Dec 14, 2023
1 parent 3c82c30 commit 3fa6a8d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ jobs:
## Install Qt.
brew install -q qt@6
## Install other tools.
brew install -q gnu-sed
brew install -q gnu-sed diffutils
## Install Python tools.
pip3 install --user --upgrade codespell
Expand Down
9 changes: 7 additions & 2 deletions build/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,14 @@ def match_file(expected_path, actual_path):
filtered_actual_path = filter_file(actual_path)
diff_path = actual_path + ".diff"
with open(diff_path, "w", encoding="utf-8") as diff_fd:
# `-B` to ignore blank lines.
exit_code = subprocess.call(
[DIFF_EXE, "-B", filtered_expected_path, filtered_actual_path],
[
DIFF_EXE,
"--ignore-blank-lines",
"--ignore-trailing-space",
filtered_expected_path,
filtered_actual_path,
],
stdout=diff_fd,
)
return exit_code == 0, diff_path
Expand Down
10 changes: 8 additions & 2 deletions tests/_test_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ add_test_command(
add_test_command(
NAME "_test_driver::check_stdout"
MATCH_STDOUT "output_1.txt"
COMMAND "${BASH_EXE}" -c "echo Some output.")
COMMAND "${BASH_EXE}" -c "echo 'Some output.'")
add_test_command(
NAME "_test_driver::check_stderr"
MATCH_STDERR "output_2.txt"
COMMAND "${BASH_EXE}" -c "echo Some different output. 1>&2 ")
COMMAND "${BASH_EXE}" -c "echo 'Some different output.' 1>&2 ")

# Check that the output files are captured correctly.
add_test_command(
Expand All @@ -56,6 +56,12 @@ add_test_command(

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #

# Check that the empty lines are ignored when matching files.
add_test_command(
NAME "_test_driver::ignore_trailing_whitespaces"
MATCH_STDOUT "output_1.txt"
COMMAND "${BASH_EXE}" -c "echo 'Some output. '")

# Check that the empty lines are ignored when matching files.
add_test_command(
NAME "_test_driver::ignore_empty_lines"
Expand Down

0 comments on commit 3fa6a8d

Please sign in to comment.