3 # (Be in -*- python -*- mode.)
5 # ====================================================================
6 # Copyright (c) 2007 CollabNet. All rights reserved.
8 # This software is licensed as described in the file COPYING, which
9 # you should have received as part of this distribution. The terms
10 # are also available at http://subversion.tigris.org/license-1.html.
11 # If newer versions of this license are posted there, you may use a
12 # newer version instead, at your option.
14 # This software consists of voluntary contributions made by many
15 # individuals. For exact contribution history, see the revision
16 # history and logs, available at http://viewvc.tigris.org/.
17 # ====================================================================
19 """Run tests of rcsparse code."""
24 from cStringIO
import StringIO
25 from difflib
import Differ
27 # Since there is nontrivial logic in __init__.py, we have to import
28 # parse() via that file. First make sure that the directory
29 # containing this script is in the path:
30 script_dir
= os
.path
.dirname(sys
.argv
[0])
31 sys
.path
.insert(0, script_dir
)
33 from __init__
import parse
34 from parse_rcs_file
import LoggingSink
37 test_dir
= os
.path
.join(script_dir
, 'test-data')
39 filelist
= glob
.glob(os
.path
.join(test_dir
, '*,v'))
44 for filename
in filelist
:
45 sys
.stderr
.write('%s: ' % (filename
,))
48 parse(open(filename
, 'rb'), LoggingSink(f
))
50 sys
.stderr
.write('Error parsing file: %s!\n' % (e
,))
55 expected_output_filename
= filename
[:-2] + '.out'
56 expected_output
= open(expected_output_filename
, 'rb').read()
58 if output
== expected_output
:
59 sys
.stderr
.write('OK\n')
61 sys
.stderr
.write('Output does not match expected output!\n')
63 for diffline
in differ
.compare(
64 expected_output
.splitlines(1), output
.splitlines(1)
66 sys
.stderr
.write(diffline
)