mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-11-21 03:13:05 +08:00
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
This commit is contained in:
parent
05506510de
commit
628c1d1f2c
@ -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");
|
||||
|
@ -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
|
||||
|
||||
/*
|
||||
|
@ -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");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user