From 8e5aa7cfe7b873b4eb8dd522054e16a67fb66ca8 Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Tue, 13 Dec 2011 23:06:06 +1030 Subject: Update build testing to show test counts/failures Display failed tests, and successful/total test counts. Use "awk" to provide a portable "ggrep -E" with context. --- tests/common.lua | 14 ++++++++++++-- tests/test.lua | 8 ++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/common.lua b/tests/common.lua index 0b231bd..f3dc6f7 100644 --- a/tests/common.lua +++ b/tests/common.lua @@ -176,6 +176,13 @@ function compare_values(val1, val2) return true end +local test_count_pass = 0 +local test_count_total = 0 + +function run_test_summary() + return test_count_pass, test_count_total +end + function run_test(testname, func, input, should_work, output) local function status_line(name, status, value) local statusmap = { [true] = ":success", [false] = ":error" } @@ -191,10 +198,13 @@ function run_test(testname, func, input, should_work, output) local correct = false if success == should_work and compare_values(result, output) then correct = true + test_count_pass = test_count_pass + 1 end + test_count_total = test_count_total + 1 local teststatus = { [true] = "PASS", [false] = "FAIL" } - print("==> Test " .. testname .. ": " .. teststatus[correct]) + print(string.format("==> Test[%d] / %s: %s", + test_count_total, testname, teststatus[correct])) status_line("Input", nil, input) if not correct then @@ -216,7 +226,7 @@ function run_test_group(testgroup, tests) end local function test_id(group, id) - return string.format("%s [%d]", group, id) + return string.format("%s[%d]", group, id) end for k, v in ipairs(tests) do diff --git a/tests/test.lua b/tests/test.lua index b7b50d2..90d216c 100755 --- a/tests/test.lua +++ b/tests/test.lua @@ -245,4 +245,12 @@ for i = 1, #arg do true, { true }) end +local pass, total = run_test_summary() + +print(string.format("==> Summary: %d/%d tests succeeded", pass, total)) + +if pass ~= total then + os.exit(1) +end + -- vi:ai et sw=4 ts=4: -- cgit v1.2.3-55-g6feb