Updated Branches: refs/heads/clownfish-test [created] 263e9bb01
New test infrastructure Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/7f59d22d Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/7f59d22d Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/7f59d22d Branch: refs/heads/clownfish-test Commit: 7f59d22dcd7a0a7eeda28ce08da46cc34ac0e41d Parents: b751260 Author: Nick Wellnhofer <[email protected]> Authored: Fri Feb 15 21:41:08 2013 +0100 Committer: Nick Wellnhofer <[email protected]> Committed: Fri Feb 15 23:54:24 2013 +0100 ---------------------------------------------------------------------- core/Clownfish/Test/Formatter/TestFormatterTAP.c | 79 ++++ core/Clownfish/Test/Formatter/TestFormatterTAP.cfh | 45 ++ core/Clownfish/Test/TestBatch.c | 48 +++ core/Clownfish/Test/TestBatch.cfh | 39 ++ core/Clownfish/Test/TestEngine.c | 312 +++++++++++++++ core/Clownfish/Test/TestEngine.cfh | 130 ++++++ core/Clownfish/Test/TestFormatter.c | 55 +++ core/Clownfish/Test/TestFormatter.cfh | 50 +++ perl/buildlib/Lucy/Build/Binding/Object.pm | 9 + 9 files changed, 767 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/7f59d22d/core/Clownfish/Test/Formatter/TestFormatterTAP.c ---------------------------------------------------------------------- diff --git a/core/Clownfish/Test/Formatter/TestFormatterTAP.c b/core/Clownfish/Test/Formatter/TestFormatterTAP.c new file mode 100644 index 0000000..00d0c80 --- /dev/null +++ b/core/Clownfish/Test/Formatter/TestFormatterTAP.c @@ -0,0 +1,79 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdio.h> + +#define C_LUCY_TESTFORMATTERTAP +#define LUCY_USE_SHORT_NAMES +#define CHY_USE_SHORT_NAMES + +#include "Clownfish/Test/Formatter/TestFormatterTAP.h" +#include "Clownfish/Test/TestBatch.h" +#include "Clownfish/Test/TestEngine.h" +#include "Clownfish/VTable.h" + +TestFormatterTAP* +TestFormatterTAP_new() { + TestFormatterTAP *self + = (TestFormatterTAP*)VTable_Make_Obj(TESTFORMATTERTAP); + return TestFormatterTAP_init(self); +} + +TestFormatterTAP* +TestFormatterTAP_init(TestFormatterTAP *self) { + return (TestFormatterTAP*)TestFormatter_init((TestFormatter*)self); +} + +void +TestFormatterTAP_batch_prologue(TestFormatterTAP *self, TestBatch2 *batch) { + UNUSED_VAR(self); + printf("1..%d\n", TestBatch2_Get_Num_Planned(batch)); +} + +void +TestFormatterTAP_vtest_result(TestFormatterTAP *self, bool pass, + uint32_t test_num, const char *fmt, + va_list args) { + UNUSED_VAR(self); + const char *result = pass ? "ok" : "not ok"; + printf("%s %d - ", result, test_num); + vprintf(fmt, args); + printf("\n"); +} + +void +TestFormatterTAP_vtest_comment(TestFormatterTAP *self, const char *fmt, + va_list args) { + UNUSED_VAR(self); + printf("# "); + vprintf(fmt, args); +} + +void +TestFormatterTAP_vbatch_comment(TestFormatterTAP *self, const char *fmt, + va_list args) { + UNUSED_VAR(self); + printf("# "); + vprintf(fmt, args); +} + +void +TestFormatterTAP_summary(TestFormatterTAP *self, TestEngine *engine) { + UNUSED_VAR(self); + UNUSED_VAR(engine); +} + + http://git-wip-us.apache.org/repos/asf/lucy/blob/7f59d22d/core/Clownfish/Test/Formatter/TestFormatterTAP.cfh ---------------------------------------------------------------------- diff --git a/core/Clownfish/Test/Formatter/TestFormatterTAP.cfh b/core/Clownfish/Test/Formatter/TestFormatterTAP.cfh new file mode 100644 index 0000000..5b2e838 --- /dev/null +++ b/core/Clownfish/Test/Formatter/TestFormatterTAP.cfh @@ -0,0 +1,45 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +parcel Lucy; + +class Clownfish::Test::Formatter::TestFormatterTAP + inherits Clownfish::Test::TestFormatter { + + inert incremented TestFormatterTAP* + new(); + + inert TestFormatterTAP* + init(TestFormatterTAP *self); + + void + Batch_Prologue(TestFormatterTAP *self, TestBatch2 *batch); + + void + VTest_Result(TestFormatterTAP *self, bool pass, uint32_t test_num, + const char *fmt, va_list args); + + void + VTest_Comment(TestFormatterTAP *self, const char *fmt, va_list args); + + void + VBatch_Comment(TestFormatterTAP *self, const char *fmt, va_list args); + + void + Summary(TestFormatterTAP *self, TestEngine *engine); +} + + http://git-wip-us.apache.org/repos/asf/lucy/blob/7f59d22d/core/Clownfish/Test/TestBatch.c ---------------------------------------------------------------------- diff --git a/core/Clownfish/Test/TestBatch.c b/core/Clownfish/Test/TestBatch.c new file mode 100644 index 0000000..9fa256b --- /dev/null +++ b/core/Clownfish/Test/TestBatch.c @@ -0,0 +1,48 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define C_LUCY_TESTBATCH2 +#define LUCY_USE_SHORT_NAMES + +#include "Clownfish/Test/TestBatch.h" +#include "CLownfish/CharBuf.h" +#include "CLownfish/Err.h" + +TestBatch2* +TestBatch2_init(TestBatch2 *self, CharBuf *name, uint32_t num_planned) { + self->name = name; + self->num_planned = num_planned; + ABSTRACT_CLASS_CHECK(self, TESTBATCH2); + return self; +} + +void +TestBatch2_destroy(TestBatch2 *self) { + DECREF(self->name); + SUPER_DESTROY(self, TESTBATCH2); +} + +CharBuf* +TestBatch2_get_name(TestBatch2 *self) { + return self->name; +} + +uint32_t +TestBatch2_get_num_planned(TestBatch2 *self) { + return self->num_planned; +} + + http://git-wip-us.apache.org/repos/asf/lucy/blob/7f59d22d/core/Clownfish/Test/TestBatch.cfh ---------------------------------------------------------------------- diff --git a/core/Clownfish/Test/TestBatch.cfh b/core/Clownfish/Test/TestBatch.cfh new file mode 100644 index 0000000..672d510 --- /dev/null +++ b/core/Clownfish/Test/TestBatch.cfh @@ -0,0 +1,39 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +parcel Lucy; + +abstract class Clownfish::Test::TestBatch2 inherits Clownfish::Obj { + CharBuf *name; + uint32_t num_planned; + + inert TestBatch2* + init(TestBatch2 *self, decremented CharBuf *name, uint32_t num_planned); + + public void + Destroy(TestBatch2 *self); + + CharBuf* + Get_Name(TestBatch2 *self); + + uint32_t + Get_Num_Planned(TestBatch2 *self); + + abstract void + Run_Tests(TestBatch2 *self, TestEngine *engine); +} + + http://git-wip-us.apache.org/repos/asf/lucy/blob/7f59d22d/core/Clownfish/Test/TestEngine.c ---------------------------------------------------------------------- diff --git a/core/Clownfish/Test/TestEngine.c b/core/Clownfish/Test/TestEngine.c new file mode 100644 index 0000000..e2a6e86 --- /dev/null +++ b/core/Clownfish/Test/TestEngine.c @@ -0,0 +1,312 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <math.h> +#include <string.h> + +#define C_LUCY_TESTENGINE +#define LUCY_USE_SHORT_NAMES +#define CHY_USE_SHORT_NAMES + +#include "Clownfish/Test/TestEngine.h" +#include "Clownfish/CharBuf.h" +#include "Clownfish/Err.h" +#include "Clownfish/Test/Formatter/TestFormatterTAP.h" +#include "Clownfish/Test/TestBatch.h" +#include "Clownfish/VArray.h" +#include "Clownfish/VTable.h" + +static bool +S_vtest_true(TestEngine *self, bool condition, const char *pattern, + va_list args); + +TestEngine* +TestEngine_new(CharBuf *formatter_name) { + TestEngine *self = (TestEngine*)VTable_Make_Obj(TESTENGINE); + return TestEngine_init(self, formatter_name); +} + +TestEngine* +TestEngine_init(TestEngine *self, CharBuf *formatter_name) { + self->batches = VA_new(0); + + if (CB_Equals_Str(formatter_name, "tap", 3)) { + self->formatter = (TestFormatter*)TestFormatterTAP_new(); + } + else { + THROW(ERR, "Unknown formatter name '%s'", formatter_name); + } + + self->num_tests = 0; + self->num_tests_failed = 0; + self->num_batches = 0; + self->num_batches_failed = 0; + self->num_tests_in_batch = 0; + self->num_failed_in_batch = 0; + + return self; +} + +void +TestEngine_destroy(TestEngine *self) { + DECREF(self->batches); + DECREF(self->formatter); + SUPER_DESTROY(self, TESTENGINE); +} + +bool +TestEngine_run_batch(TestEngine *self, TestBatch2 *batch) { + TestFormatter_Batch_Prologue(self->formatter, batch); + + TestBatch2_Run_Tests(batch, self); + + bool failed = false; + + if (self->num_failed_in_batch > 0) { + failed = true; + TestFormatter_batch_comment(self->formatter, "%d/%d tests failed.\n", + self->num_failed_in_batch, + self->num_tests_in_batch); + } + + uint32_t num_planned = TestBatch2_Get_Num_Planned(batch); + if (self->num_tests_in_batch != num_planned) { + failed = true; + TestFormatter_batch_comment(self->formatter, + "Bad plan: You planned %d tests but ran" + " %d.\n", + num_planned, self->num_tests_in_batch); + } + + if (failed) { + self->num_batches_failed += 1; + } + + self->num_batches += 1; + self->num_tests_in_batch = 0; + self->num_failed_in_batch = 0; + + return !failed; +} + +bool +TestEngine_run_named_batch(TestEngine *self, CharBuf *name) { + uint32_t num_batches = VA_Get_Size(self->batches); + + for (uint32_t i = 0; i < num_batches; ++i) { + TestBatch2 *batch = (TestBatch2*)VA_Fetch(self->batches, i); + if (CB_Equals(TestBatch2_Get_Name(batch), (Obj*)name)) { + return TestEngine_Run_Batch(self, batch); + } + } + + THROW(ERR, "Couldn't find test batch '%o'", name); + UNREACHABLE_RETURN(bool); +} + +bool +TestEngine_finish(TestEngine *self) { + TestFormatter_Summary(self->formatter, self); + + return self->num_batches != 0 && self->num_batches_failed == 0; +} + +bool +TestEngine_test_true(void *vself, bool condition, const char *pattern, ...) { + va_list args; + va_start(args, pattern); + bool result = TestEngine_VTest_True((TestEngine*)vself, condition, + pattern, args); + va_end(args); + return result; +} + +bool +TestEngine_test_false(void *vself, bool condition, const char *pattern, ...) { + va_list args; + va_start(args, pattern); + bool result = TestEngine_VTest_False((TestEngine*)vself, condition, + pattern, args); + va_end(args); + return result; +} + +bool +TestEngine_test_int_equals(void *vself, long got, long expected, + const char *pattern, ...) { + va_list args; + va_start(args, pattern); + bool result = TestEngine_VTest_Int_Equals((TestEngine*)vself, got, + expected, pattern, args); + va_end(args); + return result; +} + +bool +TestEngine_test_float_equals(void *vself, double got, double expected, + const char *pattern, ...) { + va_list args; + va_start(args, pattern); + bool result = TestEngine_VTest_Float_Equals((TestEngine*)vself, got, + expected, pattern, args); + va_end(args); + return result; +} + +bool +TestEngine_test_string_equals(void *vself, const char *got, + const char *expected, const char *pattern, ...) { + va_list args; + va_start(args, pattern); + bool result = TestEngine_VTest_String_Equals((TestEngine*)vself, got, + expected, pattern, args); + va_end(args); + return result; +} + +bool +TestEngine_pass(void *vself, const char *pattern, ...) { + va_list args; + va_start(args, pattern); + bool result = TestEngine_VPass((TestEngine*)vself, pattern, args); + va_end(args); + return result; +} + +bool +TestEngine_fail(void *vself, const char *pattern, ...) { + va_list args; + va_start(args, pattern); + bool result = TestEngine_VFail((TestEngine*)vself, pattern, args); + va_end(args); + return result; +} + +void +TestEngine_skip(void *vself, const char *pattern, ...) { + va_list args; + va_start(args, pattern); + TestEngine_VSkip((TestEngine*)vself, pattern, args); + va_end(args); +} + +bool +TestEngine_vtest_true(TestEngine *self, bool condition, const char *pattern, + va_list args) { + return S_vtest_true(self, condition, pattern, args); +} + +bool +TestEngine_vtest_false(TestEngine *self, bool condition, + const char *pattern, va_list args) { + return S_vtest_true(self, !condition, pattern, args); +} + +bool +TestEngine_vtest_int_equals(TestEngine *self, long got, long expected, + const char *pattern, va_list args) { + bool pass = (got == expected); + S_vtest_true(self, pass, pattern, args); + if (!pass) { + TestFormatter_test_comment(self->formatter, + "Expected '%ld', got '%ld'.\n", + expected, got); + } + return pass; +} + +bool +TestEngine_vtest_float_equals(TestEngine *self, double got, double expected, + const char *pattern, va_list args) { + double relative_error = got / expected - 1.0; + bool pass = (fabs(relative_error) < 1e-6); + if (!pass) { + TestFormatter_test_comment(self->formatter, + "Expected '%e', got '%e'.\n", + expected, got); + } + return pass; +} + +bool +TestEngine_vtest_string_equals(TestEngine *self, const char *got, + const char *expected, const char *pattern, + va_list args) { + bool pass = (strcmp(got, expected) == 0); + S_vtest_true(self, pass, pattern, args); + if (!pass) { + TestFormatter_test_comment(self->formatter, + "Expected '%s', got '%s'.\n", + expected, got); + } + return pass; +} + +bool +TestEngine_vpass(TestEngine *self, const char *pattern, va_list args) { + return S_vtest_true(self, true, pattern, args); +} + +bool +TestEngine_vfail(TestEngine *self, const char *pattern, va_list args) { + return S_vtest_true(self, false, pattern, args); +} + +void +TestEngine_vskip(TestEngine *self, const char *pattern, va_list args) { + // TODO: Add a VTest_Skip method to TestFormatter + S_vtest_true(self, true, pattern, args); +} + +static bool +S_vtest_true(TestEngine *self, bool condition, const char *pattern, + va_list args) { + // Increment test number. + self->num_tests += 1; + self->num_tests_in_batch += 1; + + if (!condition) { + self->num_tests_failed += 1; + self->num_failed_in_batch += 1; + } + + TestFormatter_VTest_Result(self->formatter, condition, + self->num_tests_in_batch, pattern, args); + + return condition; +} + +uint32_t +TestEngine_get_num_tests(TestEngine *self) { + return self->num_tests; +} + +uint32_t +TestEngine_get_num_tests_failed(TestEngine *self) { + return self->num_tests_failed; +} + +uint32_t +TestEngine_get_num_batches(TestEngine *self) { + return self->num_batches; +} + +uint32_t +TestEngine_get_num_batches_failed(TestEngine *self) { + return self->num_batches_failed; +} + + http://git-wip-us.apache.org/repos/asf/lucy/blob/7f59d22d/core/Clownfish/Test/TestEngine.cfh ---------------------------------------------------------------------- diff --git a/core/Clownfish/Test/TestEngine.cfh b/core/Clownfish/Test/TestEngine.cfh new file mode 100644 index 0000000..e6593d8 --- /dev/null +++ b/core/Clownfish/Test/TestEngine.cfh @@ -0,0 +1,130 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +parcel Lucy; + +class Clownfish::Test::TestEngine inherits Clownfish::Obj { + VArray *batches; + TestFormatter *formatter; + uint32_t num_tests; + uint32_t num_tests_failed; + uint32_t num_batches; + uint32_t num_batches_failed; + uint32_t num_tests_in_batch; + uint32_t num_failed_in_batch; + + inert incremented TestEngine* + new(CharBuf *formatter_name); + + inert TestEngine* + init(TestEngine *self, CharBuf *formatter_name); + + public void + Destroy(TestEngine *self); + + bool + Run_Batch(TestEngine *self, TestBatch2 *batch); + + bool + Run_Named_Batch(TestEngine *self, CharBuf *name); + + bool + Finish(TestEngine *self); + + inert bool + test_true(void *vself, bool condition, const char *pattern, ...); + + inert bool + test_false(void *vself, bool condition, const char *pattern, ...); + + inert bool + test_int_equals(void *vself, long got, long expected, + const char *pattern, ...); + + inert bool + test_float_equals(void *vself, double got, double expected, + const char *pattern, ...); + + inert bool + test_string_equals(void *vself, const char *got, const char *expected, + const char *pattern, ...); + + inert bool + pass(void *vself, const char *pattern, ...); + + inert bool + fail(void *vself, const char *pattern, ...); + + inert void + skip(void *vself, const char *pattern, ...); + + bool + VTest_True(TestEngine *self, bool condition, const char *pattern, + va_list args); + + bool + VTest_False(TestEngine *self, bool condition, const char *pattern, + va_list args); + + bool + VTest_Int_Equals(TestEngine *self, long got, long expected, + const char *pattern, va_list args); + + bool + VTest_Float_Equals(TestEngine *self, double got, double expected, + const char *pattern, va_list args); + + bool + VTest_String_Equals(TestEngine *self, const char *got, + const char *expected, const char *pattern, + va_list args); + + bool + VPass(TestEngine *self, const char *pattern, va_list args); + + bool + VFail(TestEngine *self, const char *pattern, va_list args); + + void + VSkip(TestEngine *self, const char *pattern, va_list args); + + uint32_t + Get_Num_Tests(TestEngine *self); + + uint32_t + Get_Num_Tests_Failed(TestEngine *self); + + uint32_t + Get_Num_Batches(TestEngine *self); + + uint32_t + Get_Num_Batches_Failed(TestEngine *self); +} + +__C__ +#ifdef LUCY_USE_SHORT_NAMES + #define TEST_TRUE lucy_TestEngine_test_true + #define TEST_FALSE lucy_TestEngine_test_false + #define TEST_INT_EQ lucy_TestEngine_test_int_equals + #define TEST_FLOAT_EQ lucy_TestEngine_test_float_equals + #define TEST_STR_EQ lucy_TestEngine_test_string_equals + #define PASS lucy_TestEngine_pass + #define FAIL lucy_TestEngine_fail + #define SKIP lucy_TestEngine_skip +#endif +__END_C__ + + http://git-wip-us.apache.org/repos/asf/lucy/blob/7f59d22d/core/Clownfish/Test/TestFormatter.c ---------------------------------------------------------------------- diff --git a/core/Clownfish/Test/TestFormatter.c b/core/Clownfish/Test/TestFormatter.c new file mode 100644 index 0000000..207e675 --- /dev/null +++ b/core/Clownfish/Test/TestFormatter.c @@ -0,0 +1,55 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define C_LUCY_TESTFORMATTER +#define LUCY_USE_SHORT_NAMES + +#include "Clownfish/Test/TestFormatter.h" +#include "Clownfish/Err.h" + +TestFormatter* +TestFormatter_init(TestFormatter *self) { + ABSTRACT_CLASS_CHECK(self, TESTFORMATTER); + return self; +} + +void +TestFormatter_test_result(void *vself, bool pass, uint32_t test_num, + const char *fmt, ...) { + va_list args; + va_start(args, fmt); + TestFormatter_VTest_Result((TestFormatter*)vself, pass, test_num, fmt, + args); + va_end(args); +} + +void +TestFormatter_test_comment(void *vself, const char *fmt, ...) { + va_list args; + va_start(args, fmt); + TestFormatter_VTest_Comment((TestFormatter*)vself, fmt, args); + va_end(args); +} + +void +TestFormatter_batch_comment(void *vself, const char *fmt, ...) { + va_list args; + va_start(args, fmt); + TestFormatter_VBatch_Comment((TestFormatter*)vself, fmt, args); + va_end(args); +} + + http://git-wip-us.apache.org/repos/asf/lucy/blob/7f59d22d/core/Clownfish/Test/TestFormatter.cfh ---------------------------------------------------------------------- diff --git a/core/Clownfish/Test/TestFormatter.cfh b/core/Clownfish/Test/TestFormatter.cfh new file mode 100644 index 0000000..5454cc5 --- /dev/null +++ b/core/Clownfish/Test/TestFormatter.cfh @@ -0,0 +1,50 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +parcel Lucy; + +abstract class Clownfish::Test::TestFormatter inherits Clownfish::Obj { + inert TestFormatter* + init(TestFormatter *self); + + inert void + test_result(void *vself, bool pass, uint32_t test_num, const char *fmt, + ...); + + inert void + test_comment(void *vself, const char *fmt, ...); + + inert void + batch_comment(void *vself, const char *fmt, ...); + + abstract void + Batch_Prologue(TestFormatter *self, TestBatch2 *batch); + + abstract void + VTest_Result(TestFormatter *self, bool pass, uint32_t test_num, + const char *fmt, va_list args); + + abstract void + VTest_Comment(TestFormatter *self, const char *fmt, va_list args); + + abstract void + VBatch_Comment(TestFormatter *self, const char *fmt, va_list args); + + abstract void + Summary(TestFormatter *self, TestEngine *engine); +} + + http://git-wip-us.apache.org/repos/asf/lucy/blob/7f59d22d/perl/buildlib/Lucy/Build/Binding/Object.pm ---------------------------------------------------------------------- diff --git a/perl/buildlib/Lucy/Build/Binding/Object.pm b/perl/buildlib/Lucy/Build/Binding/Object.pm index 8adbbfe..f601628 100644 --- a/perl/buildlib/Lucy/Build/Binding/Object.pm +++ b/perl/buildlib/Lucy/Build/Binding/Object.pm @@ -31,6 +31,7 @@ sub bind_all { $class->bind_float32; $class->bind_float64; $class->bind_obj; + $class->bind_testengine; $class->bind_varray; $class->bind_vtable; } @@ -645,6 +646,14 @@ END_XS_CODE Clownfish::CFC::Binding::Perl::Class->register($binding); } +sub bind_testengine { + my $binding = Clownfish::CFC::Binding::Perl::Class->new( + parcel => "Lucy", + class_name => "Clownfish::Test::TestEngine", + ); + Clownfish::CFC::Binding::Perl::Class->register($binding); +} + sub bind_varray { my @hand_rolled = qw( Shallow_Copy
