Mercurial > projects > ldc
comparison tests/makewebstatistics.d @ 257:4234b014a4f2 trunk
[svn r275] improved makewebstatistics
author | ChristianK |
---|---|
date | Thu, 12 Jun 2008 18:40:47 +0200 |
parents | 26127a48bc09 |
children | 5723b7385c25 |
comparison
equal
deleted
inserted
replaced
256:26127a48bc09 | 257:4234b014a4f2 |
---|---|
331 | 331 |
332 | 332 |
333 int main(char[][] args){ | 333 int main(char[][] args){ |
334 | 334 |
335 if(args.length < 2){ | 335 if(args.length < 2){ |
336 fwritefln(stderr, "%s <log> <log> ...", args[0]); | 336 fwritefln(stderr, "%s [--regenerate] <log> <log> ...", args[0]); |
337 fwritefln(stderr, "bash example: %s $(ls reference/llvmdc*)", args[0]); | 337 fwritefln(stderr, "bash example: %s $(ls reference/llvmdc*)", args[0]); |
338 return 1; | 338 return 1; |
339 } | |
340 | |
341 bool regenerate = false; | |
342 char[][] files; | |
343 if(args[1] == "--regenerate") { | |
344 regenerate = true; | |
345 files = args[2..$]; | |
346 } else { | |
347 files = args[1..$]; | |
339 } | 348 } |
340 | 349 |
341 // make sure base path exists | 350 // make sure base path exists |
342 char[] basedir = "web"; | 351 char[] basedir = "web"; |
343 if(std.file.exists(basedir) && !std.file.isdir(basedir)) | 352 if(std.file.exists(basedir) && !std.file.isdir(basedir)) |
347 | 356 |
348 | 357 |
349 Log[char[]] logs; | 358 Log[char[]] logs; |
350 | 359 |
351 // parse log and emit per-log data if necessary | 360 // parse log and emit per-log data if necessary |
352 foreach(char[] file; args[1 .. $]){ | 361 foreach(char[] file; files){ |
353 char[] id = std.path.getBaseName(file); | 362 char[] id = std.path.getBaseName(file); |
354 char[] dirname = std.path.join(basedir, id); | 363 char[] dirname = std.path.join(basedir, id); |
355 | 364 |
356 if(std.file.exists(dirname)) { | 365 if(std.file.exists(dirname)) { |
357 if(std.file.isdir(dirname)) { | 366 if(std.file.isdir(dirname)) { |
358 writefln("Directory ", dirname, " already exists, skipping..."); | 367 if(!regenerate) { |
359 continue; | 368 writefln("Directory ", dirname, " already exists, skipping..."); |
369 continue; | |
370 } | |
360 } | 371 } |
361 else | 372 else |
362 throw new Exception(dirname ~ " is not a directory!"); | 373 throw new Exception(dirname ~ " is not a directory!"); |
363 } | 374 } |
364 else | 375 else |
386 | 397 |
387 | 398 |
388 foreach(tkey; log.tests.keys.sort) { | 399 foreach(tkey; log.tests.keys.sort) { |
389 auto test = log.tests[tkey]; | 400 auto test = log.tests[tkey]; |
390 auto result = test.r & Result.BASE_MASK; | 401 auto result = test.r & Result.BASE_MASK; |
391 resultsfile[result].writefln(test.name, " in ", test.file, "<br>"); | 402 resultsfile[result].writefln(test.name, " in ", test.file); |
392 } | 403 } |
393 | 404 |
394 | 405 |
395 BufferedFile stats = new BufferedFile(std.path.join(dirname, "stats.base"), FileMode.Out); | 406 BufferedFile stats = new BufferedFile(std.path.join(dirname, "stats.base"), FileMode.Out); |
396 scope(exit) stats.close(); | 407 scope(exit) stats.close(); |
403 stats.writefln(`<td><a href="`, std.path.join(log.id, "error.html"), `">`, log.counts[Result.ERROR], `</a></td>`); | 414 stats.writefln(`<td><a href="`, std.path.join(log.id, "error.html"), `">`, log.counts[Result.ERROR], `</a></td>`); |
404 stats.writefln(`</tr>`); | 415 stats.writefln(`</tr>`); |
405 } | 416 } |
406 | 417 |
407 // differences between logs | 418 // differences between logs |
408 foreach(int i, char[] file; args[2 .. $]){ | 419 foreach(int i, char[] file; files[1 .. $]){ |
409 char[] newid = std.path.getBaseName(args[2+i]); | 420 char[] newid = std.path.getBaseName(files[1+i]); |
410 char[] oldid = std.path.getBaseName(args[2+i-1]); | 421 char[] oldid = std.path.getBaseName(files[1+i-1]); |
411 | 422 |
412 char[] dirname = std.path.join(basedir, oldid ~ "-to-" ~ newid); | 423 char[] dirname = std.path.join(basedir, oldid ~ "-to-" ~ newid); |
413 | 424 |
414 if(std.file.exists(dirname)) { | 425 if(std.file.exists(dirname)) { |
415 if(std.file.isdir(dirname)) { | 426 if(std.file.isdir(dirname)) { |
416 writefln("Directory ", dirname, " already exists, skipping..."); | 427 if(!regenerate) { |
417 continue; | 428 writefln("Directory ", dirname, " already exists, skipping..."); |
429 continue; | |
430 } | |
418 } | 431 } |
419 else | 432 else |
420 throw new Exception(dirname ~ " is not a directory!"); | 433 throw new Exception(dirname ~ " is not a directory!"); |
421 } | 434 } |
422 else | 435 else |
431 Log tmp = new Log(id, file); | 444 Log tmp = new Log(id, file); |
432 logs[id] = tmp; | 445 logs[id] = tmp; |
433 return tmp; | 446 return tmp; |
434 } | 447 } |
435 } | 448 } |
436 newLog = getOrParse(newid, args[2+i]); | 449 newLog = getOrParse(newid, files[1+i]); |
437 oldLog = getOrParse(oldid, args[2+i-1]); | 450 oldLog = getOrParse(oldid, files[1+i-1]); |
438 | 451 |
439 int nRegressions, nImprovements, nChanges; | 452 int nRegressions, nImprovements, nChanges; |
440 auto regressionsFile = new BufferedFile(std.path.join(dirname, "regressions.html"), FileMode.Out); | 453 auto regressionsFile = new BufferedFile(std.path.join(dirname, "regressions.html"), FileMode.Out); |
441 scope(exit) regressionsFile.close(); | 454 scope(exit) regressionsFile.close(); |
442 auto improvementsFile = new BufferedFile(std.path.join(dirname, "improvements.html"), FileMode.Out); | 455 auto improvementsFile = new BufferedFile(std.path.join(dirname, "improvements.html"), FileMode.Out); |
461 } | 474 } |
462 else { | 475 else { |
463 targetFile = changesFile; | 476 targetFile = changesFile; |
464 nChanges++; | 477 nChanges++; |
465 } | 478 } |
466 targetFile.writefln(toString(oldT.r), " -> ", toString(t.r), " : ", t.name, " in ", t.file, "<br>"); | 479 targetFile.writefln(toString(oldT.r), " -> ", toString(t.r), " : ", t.name, " in ", t.file); |
467 } | 480 } |
468 } | 481 } |
469 | 482 |
470 BufferedFile stats = new BufferedFile(std.path.join(dirname, "stats.base"), FileMode.Out); | 483 BufferedFile stats = new BufferedFile(std.path.join(dirname, "stats.base"), FileMode.Out); |
471 scope(exit) stats.close(); | 484 scope(exit) stats.close(); |
500 <th style="padding-left:1em;padding-right:1em;">XPASS</th> | 513 <th style="padding-left:1em;padding-right:1em;">XPASS</th> |
501 <th style="padding-left:1em;padding-right:1em;">ERROR</th> | 514 <th style="padding-left:1em;padding-right:1em;">ERROR</th> |
502 </tr> | 515 </tr> |
503 `); | 516 `); |
504 | 517 |
505 for(int i = args.length - 1; i >= 1; --i) { | 518 for(int i = files.length - 1; i >= 0; --i) { |
506 auto file = args[i]; | 519 auto file = files[i]; |
507 char[] id = std.path.getBaseName(file); | 520 char[] id = std.path.getBaseName(file); |
508 char[] statsname = std.path.join(std.path.join(basedir, id), "stats.base"); | 521 char[] statsname = std.path.join(std.path.join(basedir, id), "stats.base"); |
509 index.writef(cast(char[])std.file.read(statsname)); | 522 index.writef(cast(char[])std.file.read(statsname)); |
510 | 523 |
511 if(i == 1) | 524 if(i == 0) |
512 continue; | 525 continue; |
513 | 526 |
514 char[] newid = std.path.getBaseName(args[i-1]); | 527 char[] newid = std.path.getBaseName(files[i-1]); |
515 statsname = std.path.join(std.path.join(basedir, newid ~ "-to-" ~ id), "stats.base"); | 528 statsname = std.path.join(std.path.join(basedir, newid ~ "-to-" ~ id), "stats.base"); |
516 index.writef(cast(char[])std.file.read(statsname)); | 529 index.writef(cast(char[])std.file.read(statsname)); |
517 } | 530 } |
518 | 531 |
519 index.writefln(`</table></body></html>`); | 532 index.writefln(`</table></body></html>`); |