3 """A trivial test of sorting a large number of tiny files.
5 This is mostly to verify that hierarchical merging doesn't blow up due
6 to opening too many files at once."""
13 SRCPATH
= os
.path
.normpath(os
.path
.join(os
.path
.dirname(__file__
), '..', '..'))
14 sys
.path
.insert(0, os
.path
.join(SRCPATH
))
16 from cvs2svn_lib
import sort
19 TMPDIR
= 'cvs2svn-tmp'
23 OUTFILE
= os
.path
.join(TMPDIR
, 'out.dat')
31 os
.path
.join(TMPDIR
, '%04d.dat' % (i
,))
32 for i
in range(NUMFILES
)
36 for (i
, filename
) in enumerate(filenames
):
37 f
= open(filename
, 'w')
38 for j
in range(LINES_PER_FILE
):
39 f
.write('%04d %04d\n' % (j
, i
,))
42 sort
.merge_files(filenames
, OUTFILE
, max_merge
=4)
44 for (i
, line
) in enumerate(open(OUTFILE
)):
45 assert line
== '%04d %04d\n' % (i
// NUMFILES
, i
% NUMFILES
,)