Sun, 31 Dec 2006 19:29:46 -0500
[svn] Lots of tests for various boundary cases, and slightly better handling for
some of them.
1 | 1 | #!/usr/bin/env python |
2 | # | |
3 | # compare.py -- High-level tests for x. | |
4 | # Copyright (c) 2006 Brett Smith <brettcsmith@brettcsmith.org>. | |
5 | # | |
6 | # This program is free software; you can redistribute it and/or modify it | |
7 | # under the terms of the GNU General Public License as published by the | |
8 | # Free Software Foundation; either version 2 of the License, or (at your | |
9 | # option) any later version. | |
10 | # | |
11 | # This program is distributed in the hope that it will be useful, but | |
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | |
14 | # Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU General Public License along | |
17 | # with this program; if not, write to the Free Software Foundation, Inc., | |
18 | # 51 Franklin Street, 5th Floor, Boston, MA, 02111. | |
19 | ||
20 | import os | |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
21 | import re |
1 | 22 | import subprocess |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
23 | import syck |
1 | 24 | import sys |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
25 | import tempfile |
1 | 26 | |
27 | from sets import Set as set | |
28 | ||
29 | if os.path.exists('scripts/x') and os.path.exists('tests'): | |
30 | os.chdir('tests') | |
31 | elif os.path.exists('../scripts/x') and os.path.exists('../tests'): | |
32 | pass | |
33 | else: | |
34 | print "ERROR: Can't run tests in this directory!" | |
35 | sys.exit(2) | |
36 | ||
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
37 | X_SCRIPT = os.path.realpath('../scripts/x') |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
38 | ROOT_DIR = os.path.realpath(os.curdir) |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
39 | OUTCOMES = ['error', 'failed', 'passed'] |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
40 | TESTSCRIPT_NAME = 'testscript.sh' |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
41 | SCRIPT_PROLOGUE = """#!/bin/sh |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
42 | set -e |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
43 | """ |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
44 | |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
45 | output_buffer = tempfile.TemporaryFile() |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
46 | |
1 | 47 | class ExtractorTestError(Exception): |
48 | pass | |
49 | ||
50 | ||
51 | class ExtractorTest(object): | |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
52 | def __init__(self, **kwargs): |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
53 | for key in ('name',): |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
54 | setattr(self, key, kwargs[key]) |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
55 | for key in ('directory', 'prerun', 'posttest', 'baseline', 'error', |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
56 | 'grep', 'antigrep'): |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
57 | setattr(self, key, kwargs.get(key, None)) |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
58 | for key in ('options', 'filenames'): |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
59 | setattr(self, key, kwargs.get(key, '').split()) |
1 | 60 | |
61 | def get_results(self, commands): | |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
62 | print >>output_buffer, "Output from %s:" % (' '.join(commands),) |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
63 | output_buffer.flush() |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
64 | status = subprocess.call(commands, stdout=output_buffer, |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
65 | stderr=output_buffer) |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
66 | process = subprocess.Popen(['find', '!', '-name', TESTSCRIPT_NAME], |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
67 | stdout=subprocess.PIPE) |
1 | 68 | process.wait() |
69 | output = process.stdout.read(-1) | |
70 | process.stdout.close() | |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
71 | return status, set(output.split('\n')) |
1 | 72 | |
7
1f3cb3845dfd
[svn] Add a test for recursive extraction which also makes sure that we fix
brett
parents:
1
diff
changeset
|
73 | def write_script(self, commands): |
1 | 74 | script = open(TESTSCRIPT_NAME, 'w') |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
75 | script.write("%s%s\n" % (SCRIPT_PROLOGUE, commands)) |
1 | 76 | script.close() |
77 | subprocess.call(['chmod', 'u+w', TESTSCRIPT_NAME]) | |
7
1f3cb3845dfd
[svn] Add a test for recursive extraction which also makes sure that we fix
brett
parents:
1
diff
changeset
|
78 | |
1f3cb3845dfd
[svn] Add a test for recursive extraction which also makes sure that we fix
brett
parents:
1
diff
changeset
|
79 | def get_shell_results(self): |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
80 | self.write_script(self.baseline) |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
81 | return self.get_results(['sh', TESTSCRIPT_NAME] + self.filenames) |
1 | 82 | |
83 | def get_extractor_results(self): | |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
84 | if self.prerun: |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
85 | self.write_script(self.prerun) |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
86 | subprocess.call(['sh', TESTSCRIPT_NAME]) |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
87 | return self.get_results([X_SCRIPT] + self.options + self.filenames) |
1 | 88 | |
7
1f3cb3845dfd
[svn] Add a test for recursive extraction which also makes sure that we fix
brett
parents:
1
diff
changeset
|
89 | def get_posttest_result(self): |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
90 | if not self.posttest: |
7
1f3cb3845dfd
[svn] Add a test for recursive extraction which also makes sure that we fix
brett
parents:
1
diff
changeset
|
91 | return 0 |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
92 | self.write_script(self.posttest) |
7
1f3cb3845dfd
[svn] Add a test for recursive extraction which also makes sure that we fix
brett
parents:
1
diff
changeset
|
93 | return subprocess.call(['sh', TESTSCRIPT_NAME]) |
1f3cb3845dfd
[svn] Add a test for recursive extraction which also makes sure that we fix
brett
parents:
1
diff
changeset
|
94 | |
1 | 95 | def clean(self): |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
96 | if self.directory: |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
97 | target = os.path.join(ROOT_DIR, self.directory) |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
98 | extra_options = ['!', '-name', TESTSCRIPT_NAME] |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
99 | else: |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
100 | target = ROOT_DIR |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
101 | extra_options = ['-type', 'd', |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
102 | '!', '-name', 'CVS', |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
103 | '!', '-name', '.svn'] |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
104 | status = subprocess.call(['find', target, |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
105 | '-mindepth', '1', '-maxdepth', '1'] + |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
106 | extra_options + |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
107 | ['-exec', 'rm', '-rf', '{}', ';']) |
1 | 108 | if status != 0: |
109 | raise ExtractorTestError("cleanup exited with status code %s" % | |
110 | (status,)) | |
111 | ||
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
112 | def show_status(self, status, message=None): |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
113 | raw_status = status.lower() |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
114 | if raw_status != 'passed': |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
115 | output_buffer.seek(0, 0) |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
116 | sys.stdout.write(output_buffer.read(-1)) |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
117 | if message is None: |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
118 | last_part = '' |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
119 | else: |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
120 | last_part = ': %s' % (message,) |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
121 | print "%7s: %s%s" % (status, self.name, last_part) |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
122 | return raw_status |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
123 | |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
124 | def compare_results(self, actual): |
7
1f3cb3845dfd
[svn] Add a test for recursive extraction which also makes sure that we fix
brett
parents:
1
diff
changeset
|
125 | posttest_result = self.get_posttest_result() |
1 | 126 | self.clean() |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
127 | status, expected = self.get_shell_results() |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
128 | self.clean() |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
129 | if expected != actual: |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
130 | print >>output_buffer, "Only in baseline results:" |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
131 | print >>output_buffer, '\n'.join(expected.difference(actual)) |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
132 | print >>output_buffer, "Only in actual results:" |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
133 | print >>output_buffer, '\n'.join(actual.difference(expected)) |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
134 | return self.show_status('FAILED') |
7
1f3cb3845dfd
[svn] Add a test for recursive extraction which also makes sure that we fix
brett
parents:
1
diff
changeset
|
135 | elif posttest_result != 0: |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
136 | print >>output_buffer, "Posttest gave status code", posttest_result |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
137 | return self.show_status('FAILED') |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
138 | return self.show_status('Passed') |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
139 | |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
140 | def have_error_mismatch(self, status): |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
141 | if self.error and (status == 0): |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
142 | return "x did not return expected error" |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
143 | elif (not self.error) and (status != 0): |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
144 | return "x returned error code %s" % (status,) |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
145 | return None |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
146 | |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
147 | def grep_output(self): |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
148 | output_buffer.seek(0, 0) |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
149 | output_buffer.readline() |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
150 | output = output_buffer.read(-1) |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
151 | if self.grep and (not re.search(self.grep, output)): |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
152 | return "output did not match %s" % (self.grep) |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
153 | elif self.antigrep and re.search(self.antigrep, output): |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
154 | return "output matched antigrep %s" % (self.antigrep) |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
155 | return None |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
156 | |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
157 | def check_results(self): |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
158 | output_buffer.seek(0, 0) |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
159 | output_buffer.truncate() |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
160 | self.clean() |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
161 | status, actual = self.get_extractor_results() |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
162 | problem = self.have_error_mismatch(status) or self.grep_output() |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
163 | if problem: |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
164 | return self.show_status('FAILED', problem) |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
165 | return self.compare_results(actual) |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
166 | |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
167 | def run(self): |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
168 | if self.directory: |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
169 | os.mkdir(self.directory) |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
170 | os.chdir(self.directory) |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
171 | try: |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
172 | result = self.check_results() |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
173 | except ExtractorTestError, error: |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
174 | result = self.show_status('ERROR', error) |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
175 | if self.directory: |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
176 | os.chdir(ROOT_DIR) |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
177 | subprocess.call(['chmod', '-R', '700', self.directory]) |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
178 | subprocess.call(['rm', '-rf', self.directory]) |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
179 | return result |
1 | 180 | |
181 | ||
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
182 | test_db = open('tests.yml') |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
183 | test_data = syck.load(test_db.read(-1)) |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
184 | test_db.close() |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
185 | tests = [ExtractorTest(**data) for data in test_data] |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
186 | for original_data in test_data: |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
187 | if (original_data.has_key('directory') or |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
188 | (not original_data.has_key('baseline'))): |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
189 | continue |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
190 | data = original_data.copy() |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
191 | data['name'] += ' in ..' |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
192 | data['directory'] = 'inside-dir' |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
193 | data['filenames'] = ' '.join(['../%s' % filename for filename in |
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
194 | data.get('filenames', '').split()]) |
14
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
195 | tests.append(ExtractorTest(**data)) |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
196 | results = [test.run() for test in tests] |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
197 | counts = {} |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
198 | for outcome in OUTCOMES: |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
199 | counts[outcome] = 0 |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
200 | for result in results: |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
201 | counts[result] += 1 |
6f9e1bb59719
[svn] Add support for just decompressing files that are compressed. So, if you
brett
parents:
10
diff
changeset
|
202 | print " Totals:", ', '.join(["%s %s" % (counts[key], key) for key in OUTCOMES]) |
17
481a2b4be471
[svn] Lots of tests for various boundary cases, and slightly better handling for
brett
parents:
15
diff
changeset
|
203 | output_buffer.close() |