Skip to content

Commit 59b3231

Browse files
correct some test cases broken for locales that use , instead of . for decimal numbers in human readable form
1 parent fd96bc7 commit 59b3231

4 files changed

Lines changed: 20 additions & 18 deletions

File tree

‎testsuite/hashsearch-collision-skip_test.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ def make_block(perturb_offset: int = -1, fill: int = C_BYTE) -> bytes:
5555

5656
def parse_stats(out: str):
5757
m_delta = re.search(r'hash_hits=(\d+)\s+false_alarms=(\d+)', out)
58-
m_lit = re.search(r'Literal data:\s*([\d,]+)\s*bytes', out)
59-
m_match = re.search(r'Matched data:\s*([\d,]+)\s*bytes', out)
58+
m_lit = re.search(r'Literal data:\s*([\d,.]+)\s*bytes', out)
59+
m_match = re.search(r'Matched data:\s*([\d,.]+)\s*bytes', out)
6060
if not m_delta or not m_lit or not m_match:
6161
test_fail(f"could not find deltasum/stats in rsync output:\n{out}")
6262
return (
6363
int(m_delta.group(1)),
6464
int(m_delta.group(2)),
65-
int(m_lit.group(1).replace(',', '')),
66-
int(m_match.group(1).replace(',', '')),
65+
int(m_lit.group(1).replace(',', '').replace('.', '')),
66+
int(m_match.group(1).replace(',', '').replace('.', '')),
6767
)
6868

6969

‎testsuite/hashsearch-dup-chain_test.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ def make_block(perturb_offset: int = -1, fill: int = C_BYTE) -> bytes:
3939

4040
def parse_stats(out: str):
4141
m_delta = re.search(r'hash_hits=(\d+)\s+false_alarms=(\d+)', out)
42-
m_lit = re.search(r'Literal data:\s*([\d,]+)\s*bytes', out)
43-
m_match = re.search(r'Matched data:\s*([\d,]+)\s*bytes', out)
42+
m_lit = re.search(r'Literal data:\s*([\d,.]+)\s*bytes', out)
43+
m_match = re.search(r'Matched data:\s*([\d,.]+)\s*bytes', out)
4444
if not m_delta or not m_lit or not m_match:
4545
test_fail(f"could not find deltasum/stats in rsync output:\n{out}")
4646
return (
4747
int(m_delta.group(1)),
4848
int(m_delta.group(2)),
49-
int(m_lit.group(1).replace(',', '')),
50-
int(m_match.group(1).replace(',', '')),
49+
int(m_lit.group(1).replace(',', '').replace('.', '')),
50+
int(m_match.group(1).replace(',', '').replace('.', '')),
5151
)
5252

5353

‎testsuite/output-options_test.py‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def out(*args, want_rc=0, env=None, text=True):
9595
# --- --progress shows a percentage ------------------------------------------
9696
rmtree(TODIR)
9797
p = out('-a', '--progress', f'{src}/', f'{TODIR}/')
98-
progress_re = r'[\d.,]+B\s+100%\s+[\d.,]+(?:[KMGTPE]i?)?B/s\s+\d+:\d\d:\d\d'
98+
progress_re = r'[\d,.]+B\s+100%\s+[\d,.]+(?:[KMGTPE]i?)?B/s\s+\d+:\d\d:\d\d'
9999
if not re.search(progress_re, p.stdout):
100100
test_fail(f"--progress did not show the expected final shape:\n{p.stdout}")
101101

@@ -116,17 +116,17 @@ def out(*args, want_rc=0, env=None, text=True):
116116
plain = out('-a', '--stats', f'{src}/', f'{TODIR}/').stdout
117117
rmtree(TODIR)
118118
human = out('-a', '-h', '--stats', f'{src}/', f'{TODIR}/').stdout
119-
suffix_re = r'Total file size: [\d.,]+[KMG]'
119+
suffix_re = r'Total file size: [\d,.]+[KMG]'
120120
if not re.search(suffix_re, human):
121121
test_fail(f"-h did not use a human-readable unit suffix:\n{human}")
122122
if re.search(suffix_re, plain):
123123
test_fail(f"--stats without -h unexpectedly used a unit suffix:\n{plain}")
124124

125125
for label, options, progress_re in (
126-
('default', (), r'50[,.]000B\s+100%\s+[\d.,]+[KMGTPE]B/s'),
126+
('default', (), r'50[,.]000B\s+100%\s+[\d,.]+[KMGTPE]B/s'),
127127
('--no-h', ('--no-h',), r'50000B\s+100%\s+\d+B/s'),
128-
('-h', ('-h',), r'50\.0KB\s+100%\s+[\d.,]+[KMGTPE]B/s'),
129-
('-hh', ('-hh',), r'48\.8KiB\s+100%\s+[\d.,]+[KMGTPE]iB/s'),
128+
('-h', ('-h',), r'50[,.]0KB\s+100%\s+[\d,.]+[KMGTPE]B/s'),
129+
('-hh', ('-hh',), r'48[,.]8KiB\s+100%\s+[\d,.]+[KMGTPE]iB/s'),
130130
):
131131
rmtree(TODIR)
132132
progress = out('-a', '--progress', *options, f'{src}/', f'{TODIR}/').stdout
@@ -135,23 +135,23 @@ def out(*args, want_rc=0, env=None, text=True):
135135

136136
rmtree(TODIR)
137137
human_binary = out('-a', '-hh', '--stats', f'{src}/', f'{TODIR}/').stdout
138-
if 'Total file size: 48.8Ki bytes' not in human_binary:
138+
if not re.search(r'Total file size: 48[,.]8Ki bytes', human_binary):
139139
test_fail(f"-hh did not use dynamic binary-unit precision:\n{human_binary}")
140140

141141
rmtree(src)
142142
rmtree(TODIR)
143143
makepath(src)
144144
make_data_file(src / 'threshold', 1024)
145145
threshold = out('-a', '-hh', '--stats', f'{src}/', f'{TODIR}/').stdout
146-
if 'Total file size: 1.00Ki bytes' not in threshold:
146+
if not re.search(r'Total file size: 1[,.]00Ki bytes', threshold):
147147
test_fail(f"-hh did not show an exact-threshold binary unit:\n{threshold}")
148148

149149
rmtree(src)
150150
rmtree(TODIR)
151151
makepath(src)
152152
make_data_file(src / 'below-threshold', 1000)
153153
below_threshold = out('-a', '-hh', '--stats', f'{src}/', f'{TODIR}/').stdout
154-
if 'Total file size: 1,000 bytes' not in below_threshold:
154+
if not re.search(r'Total file size: 1[,.]000 bytes', below_threshold):
155155
test_fail("-hh should preserve raw byte formatting below the binary-unit "
156156
f"threshold:\n{below_threshold}")
157157

@@ -162,7 +162,7 @@ def out(*args, want_rc=0, env=None, text=True):
162162
for i in range(999):
163163
(src / f'f{i}').touch()
164164
counts = out('-a', '-hh', '--progress', '--no-i-r', f'{src}/', f'{TODIR}/').stdout
165-
if '1,000 files to consider' not in counts:
165+
if not re.search(r'1[,.]000 files to consider', counts):
166166
test_fail(f"file-list count was not grouped:\n{counts}")
167167
rmtree(TODIR)
168168
counts = out('-a', '--no-h', '--progress', '--no-i-r', f'{src}/', f'{TODIR}/').stdout

‎testsuite/write-touched-blocks_test.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import shlex
33
import subprocess
44
import sys
5+
import re
56
from pathlib import Path
67

78
from rsyncfns import (
@@ -82,7 +83,8 @@ def run_client(src_path, dest_path):
8283
proc = run_client(base_file, dest_full)
8384
if proc.returncode != 0:
8485
test_fail(f"rsync failed on full write test:\n{proc.stdout}")
85-
if "Number of 4 KiB logical blocks touched: 1,024\n" not in proc.stdout:
86+
#if "Number of 4 KiB logical blocks touched: 1,024\n" not in proc.stdout:
87+
if not re.search(r'Number of 4 KiB logical blocks touched: 1[,.]024\n', proc.stdout):
8688
test_fail(f"Full write check failed! Expected 1,024 blocks. Output:\n{proc.stdout}")
8789

8890
# TEST 5: Sparse File Write (Hole skipping)

0 commit comments

Comments
 (0)