~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/tests/libsvn_subr/target-test.py

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
#  target-test.py:  testing svn_path_condense_targets.
 
4
#
 
5
#  Subversion is a tool for revision control.
 
6
#  See http://subversion.tigris.org for more information.
 
7
#
 
8
# ====================================================================
 
9
# Copyright (c) 2000-2004 CollabNet.  All rights reserved.
 
10
#
 
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.
 
16
#
 
17
######################################################################
 
18
 
 
19
import os, sys, shutil, string
 
20
 
 
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'),
 
26
         ('identical dirs',
 
27
          'z/A z/A z/A z/A',
 
28
          cwd + '/z/A: \n'),
 
29
         ('identical files',
 
30
          'z/A/file z/A/file z/A/file z/A/file',
 
31
          cwd + '/z/A/file: \n'),
 
32
         ('single dir',
 
33
          'z/A',
 
34
          cwd + '/z/A: \n'),
 
35
         ('single file',
 
36
          'z/A/file',
 
37
          cwd + '/z/A/file: \n'),
 
38
         ('URLs',
 
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')]
 
53
 
 
54
# (re)Create the test directory
 
55
if os.path.exists('z'):
 
56
  shutil.rmtree('z')
 
57
os.mkdir('z')
 
58
os.mkdir('z/A')
 
59
os.mkdir('z/A/B')
 
60
os.mkdir('z/A/C')
 
61
os.mkdir('z/D')
 
62
os.mkdir('z/D/E')
 
63
os.mkdir('z/D/F')
 
64
os.mkdir('z/G')
 
65
os.mkdir('z/G/H')
 
66
os.mkdir('z/G/I')
 
67
open('z/A/file', 'w').close()
 
68
 
 
69
def _run_test(cmdline):
 
70
  if sys.platform == 'win32':
 
71
    progname = '.\\target-test.exe'
 
72
  else:
 
73
    progname = './target-test'
 
74
 
 
75
  infile, outfile, errfile = os.popen3(progname + ' ' + cmdline)
 
76
  stdout_lines = outfile.readlines()
 
77
  stderr_lines = errfile.readlines()
 
78
 
 
79
  outfile.close()
 
80
  infile.close()
 
81
  errfile.close()
 
82
 
 
83
  map(sys.stdout.write, stderr_lines)
 
84
  return len(stderr_lines), string.join(stdout_lines, '')
 
85
 
 
86
# Run the tests
 
87
failed = 0
 
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])
 
91
  if status:
 
92
    print 'FAIL:', test_name, '(non-null return)'
 
93
    failed = 1
 
94
  else:
 
95
    if output != tests[n][2]:
 
96
      print 'FAIL:', test_name
 
97
      failed = 1
 
98
    else:
 
99
      print 'PASS:', test_name
 
100
sys.exit(failed)