Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 419 lines (400 sloc) 9.609 kB
18d1527 @fperrad add t/harness.pir
fperrad authored
1 #!parrot
2 # Copyright (C) 2010, Parrot Foundation.
3
4 .sub 'main' :main
5 .param pmc argv
6 $S0 = shift argv
7 .local int argc
8 argc = elements argv
9 if argc > 0 goto L1
10 help()
11 end
12 L1:
13 .local pmc opts
14 opts = _parse_opts(argv)
15 $I0 = exists opts['help']
16 unless $I0 goto L2
17 help()
18 end
19 L2:
20 .tailcall do(opts, argv)
21 .end
22
23 .sub 'help' :anon
24 say <<"HELP"
25 parrot t/harness.pir [options] [testfiles]
26 --core-tests
27 --runcore-tests
28 --code-tests
29 --archive ... create a TAP archive of the test run
30 --send-to-smolder ... send the TAP archive to the Parrot Smolder server
31 HELP
32 .end
33
34 .sub '_parse_opts' :anon
35 .param pmc argv
36 load_bytecode 'Getopt/Obj.pbc'
37 $P0 = new ['Getopt';'Obj']
38 $P0.'notOptStop'(1)
39 push $P0, 'gc-debug'
40 push $P0, 'core-tests'
41 push $P0, 'runcore-tests'
42 push $P0, 'code-tests'
43 push $P0, 'run-exec'
44 push $P0, 'archive'
45 push $P0, 'send-to-smolder'
46 push $P0, 'help|h'
47 $P1 = $P0.'get_options'(argv)
48 .return ($P1)
49 .end
50
51 .sub 'do' :anon
52 .param pmc opts
53 .param pmc files
54 set_test_prog_args(opts)
55 load_bytecode 'TAP/Harness.pbc'
56 .local pmc options, env, harness, aggregate
57 options = new 'Hash'
58 env = new 'Env'
59 $I0 = exists env['HARNESS_VERBOSE']
60 unless $I0 goto L1
61 $S0 = env['HARNESS_VERBOSE']
62 options['verbosity'] = $S0
63 L1:
64 $I0 = exists opts['archive']
65 if $I0 goto L2
66 harness = new ['TAP';'Harness']
67 options['directives'] = 1
68 goto L3
69 L2:
70 harness = new ['TAP';'Harness';'Archive']
595bffe @jkeenan Reposition parrot_test_run.tar.gz in a subdirectory (t/archive) so it…
jkeenan authored
71 harness.'archive'('t/archive/parrot_test_run.tar.gz')
18d1527 @fperrad add t/harness.pir
fperrad authored
72 options['merge'] = 1
73 .local pmc env_data
74 env_data = collect_test_environment_data()
75 harness.'extra_props'(env_data)
76 $P0 = split ' ', 'myconfig config_lib.pir'
77 harness.'extra_files'($P0)
78 L3:
79 harness.'process_args'(options)
80 $P0 = _get_tests(opts, files)
81 aggregate = harness.'runtests'($P0)
82 $I0 = exists opts['send-to-smolder']
83 unless $I0 goto L4
84 .tailcall send_archive_to_smolder(env_data)
85 L4:
86 $I0 = aggregate.'all_passed'()
87 $I0 = not $I0
88 exit $I0
89 .end
90
91 .sub 'set_test_prog_args' :anon
92 .param pmc opts
93 $S0 = ''
94 $I0 = exists opts['gc-debug']
95 unless $I0 goto L1
96 $S0 .= ' --gc-debug'
97 L1:
98 $I0 = exists opts['run-exec']
99 unless $I0 goto L2
100 $S0 .= ' --run-exec'
101 L2:
102 $S0 = substr $S0, 1
103 $P0 = new 'Env'
104 $P0['TEST_PROG_ARGS'] = $S0
105 .end
106
107 .sub '_get_tests' :anon
108 .param pmc opts
109 .param pmc files
110 .local int nb
111 $I0 = opts['code-tests']
112 unless $I0 goto L1
b87487f @leto cleanup t/distro/file_metadata.t references, plobsing++
leto authored
113 .const string developing_tests = 't/codingstd/*.t'
18d1527 @fperrad add t/harness.pir
fperrad authored
114 files = glob(developing_tests)
115 goto L2
116 L1:
117 nb = elements files
118 unless nb == 0 goto L2
119 files = _get_common_tests(opts)
120 L2:
121 nb = elements files
122 # currently, FixedStringArray hasn't the method sort.
18f3b94 @Benabik Auto-replace TT# with GH# as per GH #707
Benabik authored
123 # see GH #384
18d1527 @fperrad add t/harness.pir
fperrad authored
124 $P0 = new 'FixedPMCArray'
125 set $P0, nb
126 $I0 = 0
127 $P1 = iter files
128 L3:
129 unless $P1 goto L4
130 $S0 = shift $P1
131 $P2 = split "\\", $S0
132 $S0 = join "/", $P2
133 $P2 = box $S0
134 $P0[$I0] = $P2
135 inc $I0
136 goto L3
137 L4:
138 $P0.'sort'()
139 .return ($P0)
140 .end
141
142 .sub '_get_common_tests' :anon
143 .param pmc opts
144 .const string runcore_tests = <<'TEST'
145 t/compilers/imcc/*/*.t
146 t/op/*.t
147 t/pmc/*.t
148 t/oo/*.t
3718798 @fperrad [harness.pir] add missing files
fperrad authored
149 t/pir/*.t
18d1527 @fperrad add t/harness.pir
fperrad authored
150 t/native_pbc/*.t
151 TEST
152 .const string core_tests = <<'TEST'
153 t/src/*.t
3718798 @fperrad [harness.pir] add missing files
fperrad authored
154 t/src/embed/*.t
18d1527 @fperrad add t/harness.pir
fperrad authored
155 t/run/*.t
156 t/perl/*.t
157 TEST
158 .const string library_tests = <<'TEST'
159 t/compilers/pct/*.t
160 t/compilers/pge/*.t
161 t/compilers/pge/p5regex/*.t
162 t/compilers/pge/perl6regex/*.t
163 t/compilers/tge/*.t
3718798 @fperrad [harness.pir] add missing files
fperrad authored
164 t/compilers/opsc/*.t
165 t/compilers/data_json/*.t
166 t/dynoplibs/*.t
167 t/dynpmc/*.t
18d1527 @fperrad add t/harness.pir
fperrad authored
168 t/library/*.t
173b634 @fperrad [harness.pir] add Winxed
fperrad authored
169 t/ext/winxed/*.t
18d1527 @fperrad add t/harness.pir
fperrad authored
170 t/tools/*.t
171 t/profiling/*.t
172 TEST
173 .const string configure_tests = <<'TEST'
174 t/configure/*.t
175 t/steps/*.t
176 t/postconfigure/*.t
177 TEST
178 $S0 = runcore_tests
179 $I0 = exists opts['runcore-tests']
180 if $I0 goto L1
181 $S0 .= core_tests
182 $I0 = exists opts['core-tests']
183 if $I0 goto L1
184 $S0 .= library_tests
185 $S0 .= configure_tests
186 L1:
187 $P0 = split "\n", $S0
188 $S0 = join ' ', $P0
189 $P0 = glob($S0)
190 .return ($P0)
191 .end
192
193 .include 'iglobals.pasm'
194
195 .sub 'collect_test_environment_data' :anon
196 .local pmc config, env
197 $P0 = getinterp
198 config = $P0[.IGLOBALS_CONFIG_HASH]
199 env = new 'Env'
200 $P0 = new 'Hash'
201 .local string arch
202 arch = config['cpuarch']
203 $P0['Architecture'] = arch
204 $S0 = _get_compiler_version(config)
205 $P0['Compiler'] = $S0
206 .local string devel
207 devel = config['DEVEL']
208 $P0['DEVEL'] = devel
209 .local string optimize
210 optimize = 'none'
211 $I0 = exists config['optimize']
212 unless $I0 goto L1
213 optimize = config['optimize']
214 L1:
215 $P0['Optimize'] = optimize
5d2a92f @fperrad [harness.pir] add property 'Configure args'
fperrad authored
216
217 $I0 = exists config['configure_args']
218 unless $I0 goto L2
219 $S0 = config['configure_args']
220 $P0['Configure args'] = $S0
221 L2:
18d1527 @fperrad add t/harness.pir
fperrad authored
222 .local string osname
223 osname = config['osname']
224 $P0['Platform'] = osname
225 .local string version
226 version = config['VERSION']
227 $P0['Version'] = version
228 .local string submitter
229 submitter = _get_submitter(config, env)
230 $P0['Submitter'] = submitter
fea9faa @fperrad [smolder] swap sha1 & git_describe
fperrad authored
231 $I0 = exists config['sha1']
5d2a92f @fperrad [harness.pir] add property 'Configure args'
fperrad authored
232 unless $I0 goto L3
fea9faa @fperrad [smolder] swap sha1 & git_describe
fperrad authored
233 .local string sha1
234 sha1 = config['sha1']
235 $P0['Git sha1'] = sha1
5d2a92f @fperrad [harness.pir] add property 'Configure args'
fperrad authored
236 L3:
2fcd475 @fperrad [harness.pir] add Git info : branch & modified files
fperrad authored
237 _add_git_info($P0)
18d1527 @fperrad add t/harness.pir
fperrad authored
238 .return ($P0)
239 .end
240
241 .sub '_get_compiler_version' :anon
242 .param pmc config
243 $S0 = config['cc']
244 $I0 = index $S0, 'gcc'
245 unless $I0 >= 0 goto L1
246 $I0 = exists config['gccversion']
247 unless $I0 goto L1
248 $S0 .= ' '
249 $S1 = config['gccversion']
250 $S0 .= $S1
251 .return ($S0)
252 L1:
253 $I0 = index $S0, 'cl'
254 unless $I0 >= 0 goto L2
255 $I0 = exists config['msvcversion']
256 unless $I0 goto L2
257 $S0 .= ' '
258 $S1 = config['msvcversion']
259 $S0 .= $S1
260 .return ($S0)
261 L2:
262 $I0 = exists config['gccversion']
263 unless $I0 goto L3
264 $S0 .= ' (gcc '
265 $S1 = config['gccversion']
266 $S0 .= $S1
267 $S0 .= ')'
268 .return ($S0)
269 L3:
270 $I0 = exists config['msvcversion']
271 unless $I0 goto L4
272 $S0 .= ' (msvc '
273 $S1 = config['msvcversion']
274 $S0 .= $S1
275 $S0 .= ')'
276 .return ($S0)
277 L4:
278 .return ($S0)
279 .end
280
281 .sub '_get_submitter' :anon
282 .param pmc config
283 .param pmc env
284 $I0 = exists env['SMOLDER_SUBMITTER']
285 unless $I0 goto L1
286 $S0 = env['SMOLDER_SUBMITTER']
287 .return ($S0)
288 L1:
289 .local string me
290 $I0 = exists config['win32']
291 unless $I0 goto L2
292 me = env['USERNAME']
293 goto L3
294 L2:
295 me = env['LOGNAME']
296 L3:
297 $S0 = me . '@unknown'
298 .return ($S0)
299 .end
300
301 .include 'cclass.pasm'
302
2fcd475 @fperrad [harness.pir] add Git info : branch & modified files
fperrad authored
303 .sub '_add_git_info' :anon
304 .param pmc hash
305 $I0 = file_exists('.git')
306 unless $I0 goto L1
307 $P0 = new 'FileHandle'
308 $P0.'open'('git branch', 'pr')
309 $S0 = $P0.'readall'()
310 $P0.'close'()
311 $I0 = length $S0
312 $I1 = index $S0, '*'
313 unless $I1 >= 0 goto L2
314 $I1 += 1
315 $I1 = find_not_cclass .CCLASS_WHITESPACE, $S0, $I1, $I0
316 $I2 = find_cclass .CCLASS_WHITESPACE, $S0, $I1, $I0
317 $I3 = $I2 - $I1
318 $S1 = substr $S0, $I1, $I3
319 hash['Branch'] = $S1
320 L2:
321 $P0.'open'('git status', 'pr')
322 $P1 = new 'ResizableStringArray'
323 L3:
324 $S0 = $P0.'readline'()
325 if $S0 == '' goto L4
326 $I1 = index $S0, 'modified:'
327 unless $I1 > 0 goto L3
328 $I1 += 9
329 $S0 = chomp($S0)
330 $I0 = length $S0
331 $I1 = find_not_cclass .CCLASS_WHITESPACE, $S0, $I1, $I0
332 $S0 = substr $S0, $I1
333 push $P1, $S0
334 goto L3
335 L4:
336 $P0.'close'()
337 $I0 = elements $P1
338 unless $I0 != 0 goto L1
339 $S0 = hash['DEVEL']
340 $S0 .= ' '
341 $S1 = $I0
342 $S0 .= $S1
343 $S0 .= ' mods'
344 hash['DEVEL'] = $S0
345 $S0 = join ' ', $P1
346 hash['Modifications'] = $S0
347 L1:
348 .return (hash)
349 .end
350
18d1527 @fperrad add t/harness.pir
fperrad authored
351 .sub 'send_archive_to_smolder' :anon
352 .param pmc env_data
353 .local pmc config
354 $P0 = getinterp
355 config = $P0[.IGLOBALS_CONFIG_HASH]
b678e91 @Whiteknight reapply changes by fperrad++
Whiteknight authored
356 .local pmc contents
357 contents = new 'ResizablePMCArray' # by couple
c1c584a @fperrad [harness.pir] Smolder properties are case sensitive
fperrad authored
358 push contents, 'Architecture'
18d1527 @fperrad add t/harness.pir
fperrad authored
359 $S0 = config['cpuarch']
b678e91 @Whiteknight reapply changes by fperrad++
Whiteknight authored
360 push contents, $S0
c1c584a @fperrad [harness.pir] Smolder properties are case sensitive
fperrad authored
361 push contents, 'Platform'
18d1527 @fperrad add t/harness.pir
fperrad authored
362 $S0 = config['osname']
b678e91 @Whiteknight reapply changes by fperrad++
Whiteknight authored
363 push contents, $S0
fea9faa @fperrad [smolder] swap sha1 & git_describe
fperrad authored
364 $I0 = exists config['git_describe']
132cca9 @fperrad [t] send git revision (instead of r1)
fperrad authored
365 unless $I0 goto L0
b678e91 @Whiteknight reapply changes by fperrad++
Whiteknight authored
366 push contents, 'revision'
fea9faa @fperrad [smolder] swap sha1 & git_describe
fperrad authored
367 $S0 = config['git_describe']
b678e91 @Whiteknight reapply changes by fperrad++
Whiteknight authored
368 push contents, $S0
132cca9 @fperrad [t] send git revision (instead of r1)
fperrad authored
369 L0:
b678e91 @Whiteknight reapply changes by fperrad++
Whiteknight authored
370 push contents, 'tags'
18d1527 @fperrad add t/harness.pir
fperrad authored
371 $S0 = _get_tags(env_data)
b678e91 @Whiteknight reapply changes by fperrad++
Whiteknight authored
372 push contents, $S0
373 push contents, 'username'
374 push contents, 'parrot-autobot'
375 push contents, 'password'
d0b25ca @fperrad [t] works with the new Parrot smolder server
fperrad authored
376 push contents, 'qa_rocks'
b678e91 @Whiteknight reapply changes by fperrad++
Whiteknight authored
377 push contents, 'comments'
378 push contents, "EXPERIMENTAL t/harness.pir with LWP.pir"
379 push contents, 'report_file'
380 $P0 = new 'FixedStringArray'
381 set $P0, 1
595bffe @jkeenan Reposition parrot_test_run.tar.gz in a subdirectory (t/archive) so it…
jkeenan authored
382 $P0[0] = 't/archive/parrot_test_run.tar.gz'
b678e91 @Whiteknight reapply changes by fperrad++
Whiteknight authored
383 push contents, $P0
41ca6f0 @fperrad [LWP] split in 2 files
fperrad authored
384 load_bytecode 'LWP/UserAgent.pir'
d0b25ca @fperrad [t] works with the new Parrot smolder server
fperrad authored
385 .const string url = 'http://smolder.parrot.org/app/projects/process_add_report/1'
b678e91 @Whiteknight reapply changes by fperrad++
Whiteknight authored
386 .local pmc ua, response
387 ua = new ['LWP';'UserAgent']
4e6e5e2 @fperrad [LWP] call env_proxy()
fperrad authored
388 ua.'env_proxy'()
b678e91 @Whiteknight reapply changes by fperrad++
Whiteknight authored
389 ua.'show_progress'(1)
390 response = ua.'post'(url, contents :flat, 'form-data' :named('Content-Type'), 'close' :named('Connection'))
391 $I0 = response.'code'()
392 unless $I0 == 302 goto L1
393 $S0 = response.'content'()
394 say $S0
395 L1:
18d1527 @fperrad add t/harness.pir
fperrad authored
396 .end
397
398 .sub '_get_tags' :anon
399 .param pmc env_data
400 $P0 = split ' ', 'Architecture Compiler Platform Version'
401 $P1 = new 'ResizableStringArray'
402 L1:
403 unless $P0 goto L2
404 $S0 = shift $P0
405 $S1 = env_data[$S0]
406 push $P1, $S1
407 goto L1
408 L2:
409 $S0 = join ', ', $P1
410 .return ($S0)
411 .end
412
413
414 # Local Variables:
415 # mode: pir
416 # fill-column: 100
417 # End:
418 # vim: expandtab shiftwidth=4 ft=pir:
Something went wrong with that request. Please try again.