Debian Codegraph @

testsuite/ki73-cvs-clear-list_test.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 """KI-73 regression: a `.cvsignore` containing only `!` (the clear-list token)
3 must not abort rsync in -C (cvs-exclude) mode.
4
5 In exclude.c the CLEAR_LIST branch guarded its trailing-character check with
6 `rule->rflags & FILTRULE_NO_PREFIXES`, but NO_PREFIXES is a template-level flag
7 that is intentionally NOT inherited by individual rules (it is excluded from
8 FILTRULES_FROM_CONTAINER). The guard therefore always evaluated as "prefixes
9 allowed" for CVS rules and rsync hit exit_cleanup(RERR_SYNTAX) instead of
10 clearing the list. The fix checks `template->rflags` instead.
11
12 # Verifies: SW-REQ-078
13 """
14
15 from rsyncfns import (
16 FROMDIR, TODIR,
17 assert_exists, makepath, rmtree, run_rsync,
18 )
19
20 src = FROMDIR
21 rmtree(src)
22 rmtree(TODIR)
23 makepath(src)
24
25 # Real files that must survive the transfer.
26 (src / 'keep1.txt').write_text('one\n')
27 (src / 'keep2.txt').write_text('two\n')
28
29 # A .cvsignore whose sole content is the clear-list token. Pre-fix this drove
30 # parse_rule_tok() into the RERR_SYNTAX abort path.
31 (src / '.cvsignore').write_text('!\n')
32
33 # check=True (the default) calls test_fail() -> exit 1 on a non-zero rsync
34 # exit, which covers the abort (RERR_SYNTAX) regression directly.
35 run_rsync('-a', '-C', f'{src}/', f'{TODIR}/')
36
37 assert_exists(TODIR / 'keep1.txt', label='clear-list .cvsignore kept keep1')
38 assert_exists(TODIR / 'keep2.txt', label='clear-list .cvsignore kept keep2')
39
40 print("ki73: cvs-exclude .cvsignore '!' clear-list token no longer aborts")