3
# target-test.py: testing svn_path_condense_targets.
5
# Subversion is a tool for revision control.
6
# See http://subversion.tigris.org for more information.
8
# ====================================================================
9
# Copyright (c) 2000-2004 CollabNet. All rights reserved.
11
# This software is licensed as described in the file COPYING, which
12
# you should have received as part of this distribution. The terms
13
# are also available at http://subversion.tigris.org/license-1.html.
14
# If newer versions of this license are posted there, you may use a
15
# newer version instead, at your option.
17
######################################################################
19
import os, sys, shutil, string
21
# The list of test cases: [(name, params, expected) ...]
22
cwd = os.getcwd().replace('\\', '/') # Use forward slashes on Windows
23
tests = [('normal use',
24
'z/A/B z/A z/A/C z/D/E z/D/F z/D z/G z/G/H z/G/I',
25
cwd + '/z: A, D, G, \n'),
30
'z/A/file z/A/file z/A/file z/A/file',
31
cwd + '/z/A/file: \n'),
37
cwd + '/z/A/file: \n'),
39
'http://host/A/C http://host/A/C/D http://host/A/B/D',
40
'http://host/A: C, B/D, \n'),
41
('URLs with no common prefix',
42
'http://host1/A/C http://host2/A/C/D http://host3/A/B/D',
43
': http://host1/A/C, http://host2/A/C/D, http://host3/A/B/D, \n'),
44
('file URLs with no common prefix',
45
'file:///A/C file:///B/D',
46
': file:///A/C, file:///B/D, \n'),
47
('URLs with mixed protocols',
48
'http://host/A/C file:///B/D gopher://host/A',
49
': http://host/A/C, file:///B/D, gopher://host/A, \n'),
50
('mixed paths and URLs',
51
'z/A/B z/A http://host/A/C/D http://host/A/C',
52
': ' + cwd + '/z/A, http://host/A/C, \n')]
54
# (re)Create the test directory
55
if os.path.exists('z'):
67
open('z/A/file', 'w').close()
69
def _run_test(cmdline):
70
if sys.platform == 'win32':
71
progname = '.\\target-test.exe'
73
progname = './target-test'
75
infile, outfile, errfile = os.popen3(progname + ' ' + cmdline)
76
stdout_lines = outfile.readlines()
77
stderr_lines = errfile.readlines()
83
map(sys.stdout.write, stderr_lines)
84
return len(stderr_lines), string.join(stdout_lines, '')
88
for n in range(len(tests)):
89
test_name = 'target-test %d: %s' % (n + 1, tests[n][0])
90
status, output = _run_test(tests[n][1])
92
print 'FAIL:', test_name, '(non-null return)'
95
if output != tests[n][2]:
96
print 'FAIL:', test_name
99
print 'PASS:', test_name