Mailing List Archive

r3816 - in trunk: charmonizer charmonizer/src/Charmonizer perl perl/buildlib/Lucy perl/t
Author: creamyg
Date: 2008-09-05 19:39:48 -0700 (Fri, 05 Sep 2008)
New Revision: 3816

Modified:
trunk/charmonizer/charm_test.c
trunk/charmonizer/src/Charmonizer/Test.charm
trunk/perl/Build.PL
trunk/perl/buildlib/Lucy/Build.pm
trunk/perl/t/003-charmonizer.t
Log:
Have Charmonizer's tests generate TAP.


Modified: trunk/charmonizer/charm_test.c
===================================================================
--- trunk/charmonizer/charm_test.c 2008-09-06 02:29:05 UTC (rev 3815)
+++ trunk/charmonizer/charm_test.c 2008-09-06 02:39:48 UTC (rev 3816)
@@ -1,10 +1,41 @@
#include <stdio.h>
+#include "Charmonizer/Test.h"
#include "Charmonizer/Test/AllTests.h"

-int main() {
+int main(int argc, char *argv[])
+{
+ int i;

+ if (argc < 2) {
+ fprintf(stderr, "usage: charm_test TEST_ID");
+ return 1;
+ }
+
chaz_AllTests_init();
- chaz_AllTests_run();
+ if (strcmp(argv[1], "integers") == 0) {
+ chaz_TestBatch *batch = chaz_TIntegers_prepare();
+ batch->run_test(batch);
+ }
+ else if (strcmp(argv[1], "func_macro") == 0) {
+ chaz_TestBatch *batch = chaz_TFuncMacro_prepare();
+ batch->run_test(batch);
+ }
+ else if (strcmp(argv[1], "headers") == 0) {
+ chaz_TestBatch *batch = chaz_THeaders_prepare();
+ batch->run_test(batch);
+ }
+ else if (strcmp(argv[1], "large_files") == 0) {
+ chaz_TestBatch *batch = chaz_TLargeFiles_prepare();
+ batch->run_test(batch);
+ }
+ else if (strcmp(argv[1], "unused_vars") == 0) {
+ chaz_TestBatch *batch = chaz_TUnusedVars_prepare();
+ batch->run_test(batch);
+ }
+ else if (strcmp(argv[1], "variadic_macros") == 0) {
+ chaz_TestBatch *batch = chaz_TVariadicMacros_prepare();
+ batch->run_test(batch);
+ }

return 0;
}

Modified: trunk/charmonizer/src/Charmonizer/Test.charm
===================================================================
--- trunk/charmonizer/src/Charmonizer/Test.charm 2008-09-06 02:29:05 UTC (rev 3815)
+++ trunk/charmonizer/src/Charmonizer/Test.charm 2008-09-06 02:39:48 UTC (rev 3816)
@@ -12,6 +12,12 @@
static void
TestBatch_run_test(TestBatch *batch);

+#define PRINT_SUPPLIED_MESS(_pattern, _args) \
+ va_start(args, pat); \
+ vprintf(pat, args); \
+ va_end(args); \
+ printf("\n");
+
void
chaz_Test_init(void) {
/* unbuffer stdout */
@@ -53,18 +59,10 @@
TestBatch_run_test(TestBatch *batch)
{
/* print start */
- printf("===================================\n");
- printf("%s - %u tests to run\n", batch->name, batch->num_tests);
- printf("===================================\n");
+ printf("1..%u\n", batch->num_tests);

/* run the batch */
batch->test_func(batch);
-
- /* print report */
- printf("-------------------------\n");
- printf("Tests: %d\nPassed: %d\nFailed: %d\nSkipped: %d\n\n",
- batch->num_tests, batch->num_passed, batch->num_failed,
- batch->num_skipped);
}

void
@@ -77,19 +75,15 @@

/* test condition and pass or fail */
if (value) {
- printf("%-4u pass: ", batch->test_num);
+ printf("ok %u - ", batch->test_num);
batch->num_passed++;
}
else {
- printf("%-4u fail: ", batch->test_num);
+ printf("not ok %u - ", batch->test_num);
batch->num_failed++;
}

- /* print supplied message */
- va_start(args, pat);
- vprintf(pat, args);
- va_end(args);
- printf("\n");
+ PRINT_SUPPLIED_MESS(pat, args);
}

void
@@ -102,20 +96,15 @@

/* test condition and pass or fail */
if (value == 0) {
- printf("%-4u pass: ", batch->test_num);
+ printf("ok %u - ", batch->test_num);
batch->num_passed++;
}
else {
- printf("%-4u fail: ", batch->test_num);
+ printf("not ok %u - ", batch->test_num);
batch->num_failed++;
}

- /* print supplied message */
- va_start(args, pat);
- vprintf(pat, args);
- va_end(args);
-
- printf("\n");
+ PRINT_SUPPLIED_MESS(pat, args);
}

void
@@ -129,20 +118,16 @@

/* test condition and pass or fail */
if (strcmp(expected, got) == 0) {
- printf("%-4u pass: ", batch->test_num);
+ printf("ok %u - ", batch->test_num);
batch->num_passed++;
}
else {
- printf("%-4u fail: Expected '%s', got '%s'\n ", batch->test_num,
+ printf("not ok %u - Expected '%s', got '%s'\n ", batch->test_num,
expected, got);
batch->num_failed++;
}

- /* print supplied message */
- va_start(args, pat);
- vprintf(pat, args);
- va_end(args);
- printf("\n");
+ PRINT_SUPPLIED_MESS(pat, args);
}


@@ -157,20 +142,16 @@

/* test condition and pass or fail */
if (strcmp(expected, got) != 0) {
- printf("%-4u pass: ", batch->test_num);
+ printf("ok %u - ", batch->test_num);
batch->num_passed++;
}
else {
- printf("%-4u fail: Expected '%s', got '%s'\n ", batch->test_num,
+ printf("not ok %u - Expected '%s', got '%s'\n ", batch->test_num,
expected, got);
batch->num_failed++;
}

- /* print supplied message */
- va_start(args, pat);
- vprintf(pat, args);
- va_end(args);
- printf("\n");
+ PRINT_SUPPLIED_MESS(pat, args);
}

void
@@ -182,14 +163,10 @@
batch->test_num++;

/* indicate pass, update pass counter */
- printf("%-4u pass: ", batch->test_num);
+ printf("ok %u - ", batch->test_num);
batch->num_passed++;

- /* print supplied message */
- va_start(args, pat);
- vprintf(pat, args);
- va_end(args);
- printf("\n");
+ PRINT_SUPPLIED_MESS(pat, args);
}

void
@@ -201,14 +178,10 @@
batch->test_num++;

/* indicate failure, update pass counter */
- printf("%-4u fail:\n", batch->test_num);
+ printf("not ok %u - ", batch->test_num);
batch->num_failed++;

- /* print supplied message */
- va_start(args, pat);
- vprintf(pat, args);
- va_end(args);
- printf("\n");
+ PRINT_SUPPLIED_MESS(pat, args);
}

void
@@ -221,20 +194,16 @@
batch->test_num++;

if (expected == got) {
- printf("%-4u pass: ", batch->test_num);
+ printf("ok %u - ", batch->test_num);
batch->num_passed++;
}
else {
- printf("%-4u fail: Expected '%ld', got '%ld'\n ", batch->test_num,
+ printf("not ok %u - Expected '%ld', got '%ld'\n ", batch->test_num,
expected, got);
batch->num_failed++;
}

- /* print supplied message */
- va_start(args, pat);
- vprintf(pat, args);
- va_end(args);
- printf("\n");
+ PRINT_SUPPLIED_MESS(pat, args);
}

void
@@ -249,21 +218,16 @@

/* evaluate condition and pass or fail */
if (diff > 0.00001) {
- printf("%-4u pass: ", batch->test_num);
+ printf("ok %u - ", batch->test_num);
batch->num_passed++;
}
else {
- printf("%-4u fail: Expected '%f', got '%f'\n ", batch->test_num,
+ printf("not ok %u - Expected '%f', got '%f'\n ", batch->test_num,
expected, got);
batch->num_failed++;
}

- /* print supplied message */
- va_start(args, pat);
- vprintf(pat, args);
- va_end(args);
- printf("\n");
-
+ PRINT_SUPPLIED_MESS(pat, args);
}

void
@@ -275,14 +239,10 @@
batch->test_num++;

/* indicate that test is being skipped, update pass counter */
- printf("%-4d skip: ", batch->test_num);
+ printf("ok %u # SKIP ", batch->test_num);
batch->num_skipped++;

- /* print supplied message */
- va_start(args, pat);
- vprintf(pat, args);
- va_end(args);
- printf("\n");
+ PRINT_SUPPLIED_MESS(pat, args);
}

void
@@ -290,16 +250,14 @@
{
va_list args;
unsigned remaining = batch->num_tests - batch->test_num;
+ unsigned i;

/* indicate that tests are being skipped, update skip counter */
- batch->num_skipped += remaining;
- printf("Skipping all %u remaining tests: ", remaining);
-
- /* print supplied message */
- va_start(args, pat);
- vprintf(pat, args);
- va_end(args);
- printf("\n");
+ printf("# Skipping all %u remaining tests: ", remaining);
+ PRINT_SUPPLIED_MESS(pat, args);
+ while (batch->test_num < batch->num_tests) {
+ SKIP(batch, "");
+ }
}

/* Copyright 2006-2007 Marvin Humphrey

Modified: trunk/perl/Build.PL
===================================================================
--- trunk/perl/Build.PL 2008-09-06 02:29:05 UTC (rev 3815)
+++ trunk/perl/Build.PL 2008-09-06 02:39:48 UTC (rev 3816)
@@ -48,7 +48,7 @@
'ExtUtils::CBuilder' => 0,
'ExtUtils::ParseXS' => 0,
'Parse::RecDescent' => 0,
- 'TAP::Harness' => 3,
+ 'TAP::Harness' => 3.12,
},
create_makefile_pl => 'passthrough',
add_to_cleanup =>

Modified: trunk/perl/buildlib/Lucy/Build.pm
===================================================================
--- trunk/perl/buildlib/Lucy/Build.pm 2008-09-06 02:29:05 UTC (rev 3815)
+++ trunk/perl/buildlib/Lucy/Build.pm 2008-09-06 02:39:48 UTC (rev 3816)
@@ -510,10 +510,28 @@
lib => [
catdir( $self->blib, 'arch' ),
catdir( $self->blib, 'lib' ),
- ]
+ ],
+ exec => sub {
+ my ( $harness, $test_file ) = @_;
+ if ( $test_file =~ /charm_test/ ) {
+ return [$test_file];
+ }
+ return undef;
+ },
}
);
- $harness->runtests( @{ $self->test_files } );
+ my @test_files = @{ $self->test_files };
+ if ( grep {m/charmonizer/} @test_files ) {
+ unshift @test_files, map { "charm_test $_" } qw(
+ integers
+ func_macro
+ headers
+ large_files
+ unused_vars
+ variadic_macros
+ );
+ }
+ $harness->runtests(@test_files);
}

# copied from Module::Build::Base.pm, added exclude '#' and follow symlinks

Modified: trunk/perl/t/003-charmonizer.t
===================================================================
--- trunk/perl/t/003-charmonizer.t 2008-09-06 02:29:05 UTC (rev 3815)
+++ trunk/perl/t/003-charmonizer.t 2008-09-06 02:39:48 UTC (rev 3816)
@@ -1,22 +1,5 @@
use strict;
use warnings;
-
use Test::More tests => 1;
+pass("Dummy test");

-use File::Spec::Functions qw( curdir );
-use Env qw( @PATH );
-
-unshift @PATH, curdir();
-my $VALGRIND = $ENV{CHARM_VALGRIND} ? "valgrind --leak-check=full " : "";
-
-# Capture and parse output of 'charm_test'.
-my $charm_test_output = qx|$VALGRIND charm_test|;
-$charm_test_output =~ /TOTAL FAILED:\s*(\d+)/
- or die "Didn't receive expected output from 'charm_test'";
-my $total_failed = $1;
-
-is( $total_failed, 0, "No failures in Charmonizer's test suite" );
-if ($total_failed) {
- print STDERR "\n$charm_test_output\n";
-}
-


_______________________________________________
kinosearch-commits mailing list
kinosearch-commits@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch-commits