Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 628c1d1

Browse files
committed
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/20240707052030.r77hbdkid3mwksop@awork3.anarazel.de
1 parent 0550651 commit 628c1d1

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/test/modules/test_json_parser/t/003_test_semantic.pl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929

3030
close($fh);
3131

32-
($stdout, $stderr) = run_command([ "diff", "-u", $fname, $test_out ]);
32+
my @diffopts = ("-u");
33+
push(@diffopts, "--strip-trailing-cr") if $windows_os;
34+
($stdout, $stderr) = run_command([ "diff", @diffopts, $fname, $test_out ]);
3335

3436
is($stdout, "", "no output diff");
3537
is($stderr, "", "no diff error");

src/test/regress/pg_regress.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ static char *shellprog = SHELLPROG;
6565
const char *basic_diff_opts = "";
6666
const char *pretty_diff_opts = "-U3";
6767
#else
68-
const char *basic_diff_opts = "-w";
69-
const char *pretty_diff_opts = "-w -U3";
68+
const char *basic_diff_opts = "--strip-trailing-cr";
69+
const char *pretty_diff_opts = "--strip-trailing-cr -U3";
7070
#endif
7171

7272
/*

src/tools/pg_bsd_indent/t/001_pg_bsd_indent.pl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
# Any diffs in the generated files will be accumulated here.
2727
my $diffs_file = "test.diffs";
2828

29+
# options used with diff
30+
my @diffopts = ("-upd");
31+
push(@diffopts, "--strip-trailing-cr") if $windows_os;
32+
2933
# Copy support files to current dir, so *.pro files don't need to know path.
3034
while (my $file = glob("$src_dir/tests/*.list"))
3135
{
@@ -45,7 +49,7 @@
4549
],
4650
"pg_bsd_indent succeeds on $test");
4751
# check result matches, adding any diff to $diffs_file
48-
my $result = run_log([ 'diff', '-upd', "$test_src.stdout", "$test.out" ],
52+
my $result = run_log([ 'diff', @diffopts, "$test_src.stdout", "$test.out" ],
4953
'>>', $diffs_file);
5054
ok($result, "pg_bsd_indent output matches for $test");
5155
}

0 commit comments

Comments
 (0)