diff options
author | Andrew Dunstan | 2024-07-10 13:53:47 +0000 |
---|---|---|
committer | Andrew Dunstan | 2024-07-10 13:53:47 +0000 |
commit | 628c1d1f2c82f1983e5248b5dfe53170dc23d90a (patch) | |
tree | 9f55771f44202e0db180dda5d151f04c35a4e6be | |
parent | 05506510de6ae24ba6de00cef2f458920c8a72ea (diff) |
Use diff's --strip-trailing-cr flag where appropriate on Windows
Test result files might be checked out using Unix or Windows style line
endings, depening on git flags, so on Windows we use the
--strip-trailing-cr flag to tell diff to ignore line endings
differences.
The flag is added to the diff invocation for the test_json_parser module
tests and the pg_bsd_indent tests. in pg_regress.c we replace the
current use of the "-w" flag, which ignore all white space differences,
with this one which only ignores line end differences.
Discussion: https://postgr.es/m/[email protected]
-rw-r--r-- | src/test/modules/test_json_parser/t/003_test_semantic.pl | 4 | ||||
-rw-r--r-- | src/test/regress/pg_regress.c | 4 | ||||
-rw-r--r-- | src/tools/pg_bsd_indent/t/001_pg_bsd_indent.pl | 6 |
3 files changed, 10 insertions, 4 deletions
diff --git a/src/test/modules/test_json_parser/t/003_test_semantic.pl b/src/test/modules/test_json_parser/t/003_test_semantic.pl index 74e0fa5bb18..b6553bbcddf 100644 --- a/src/test/modules/test_json_parser/t/003_test_semantic.pl +++ b/src/test/modules/test_json_parser/t/003_test_semantic.pl @@ -29,7 +29,9 @@ print $fh $stdout, "\n"; close($fh); -($stdout, $stderr) = run_command([ "diff", "-u", $fname, $test_out ]); +my @diffopts = ("-u"); +push(@diffopts, "--strip-trailing-cr") if $windows_os; +($stdout, $stderr) = run_command([ "diff", @diffopts, $fname, $test_out ]); is($stdout, "", "no output diff"); is($stderr, "", "no diff error"); diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index 7e7ad256000..9ff0a2d65e2 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -65,8 +65,8 @@ static char *shellprog = SHELLPROG; const char *basic_diff_opts = ""; const char *pretty_diff_opts = "-U3"; #else -const char *basic_diff_opts = "-w"; -const char *pretty_diff_opts = "-w -U3"; +const char *basic_diff_opts = "--strip-trailing-cr"; +const char *pretty_diff_opts = "--strip-trailing-cr -U3"; #endif /* diff --git a/src/tools/pg_bsd_indent/t/001_pg_bsd_indent.pl b/src/tools/pg_bsd_indent/t/001_pg_bsd_indent.pl index 24a9e80fa01..9e23ab96161 100644 --- a/src/tools/pg_bsd_indent/t/001_pg_bsd_indent.pl +++ b/src/tools/pg_bsd_indent/t/001_pg_bsd_indent.pl @@ -26,6 +26,10 @@ program_version_ok('pg_bsd_indent'); # Any diffs in the generated files will be accumulated here. my $diffs_file = "test.diffs"; +# options used with diff +my @diffopts = ("-upd"); +push(@diffopts, "--strip-trailing-cr") if $windows_os; + # Copy support files to current dir, so *.pro files don't need to know path. while (my $file = glob("$src_dir/tests/*.list")) { @@ -45,7 +49,7 @@ while (my $test_src = glob("$src_dir/tests/*.0")) ], "pg_bsd_indent succeeds on $test"); # check result matches, adding any diff to $diffs_file - my $result = run_log([ 'diff', '-upd', "$test_src.stdout", "$test.out" ], + my $result = run_log([ 'diff', @diffopts, "$test_src.stdout", "$test.out" ], '>>', $diffs_file); ok($result, "pg_bsd_indent output matches for $test"); } |