Changeset 9 for trunk/epic

Show
Ignore:
Timestamp:
08/17/08 01:47:59 (4 years ago)
Author:
fumanchu
Message:

Removed the suite_results type in favor of directly using test.results.

Location:
trunk/epic
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/epic/epic.sql

    r8 r9  
    190190  BEGIN 
    191191    CREATE TABLE test.results (name text PRIMARY KEY, module text, 
    192                                ok boolean, errcode text, errmsg text); 
    193   EXCEPTION WHEN duplicate_table THEN 
    194     NULL; 
    195   END; 
    196    
    197   BEGIN 
    198     CREATE TYPE test.suite_results AS (name text, module text, result text, 
    199                                        errcode text, errmsg text); 
     192                               result text, errcode text, errmsg text); 
    200193  EXCEPTION WHEN duplicate_table THEN 
    201194    NULL; 
     
    219212 
    220213 
    221 CREATE OR REPLACE FUNCTION test.run_test(testname text) RETURNS test.suite_results AS $$ 
     214CREATE OR REPLACE FUNCTION test.run_test(testname text) RETURNS test.results AS $$ 
    222215-- Runs the named test, stores in test.results, and returns success. 
    223216DECLARE 
    224217  modulename      text; 
    225   output_record   test.suite_results%ROWTYPE; 
     218  output_record   test.results%ROWTYPE; 
    226219BEGIN 
    227220  SELECT module INTO modulename FROM test.testnames WHERE name = testname; 
     
    231224    EXECUTE 'SELECT * FROM test.' || testname || '();'; 
    232225  EXCEPTION WHEN OTHERS THEN 
    233     IF SQLERRM = '[OK]' THEN 
    234       INSERT INTO test.results (name, module, ok) 
    235         VALUES (testname, modulename, TRUE) 
    236         RETURNING name, module, CASE WHEN ok=true THEN '[OK]' ELSE '[FAIL]' END, errcode, errmsg 
    237         INTO output_record; 
     226    IF SQLERRM LIKE '[%]' THEN 
     227      INSERT INTO test.results (name, module, result) 
     228        VALUES (testname, modulename, SQLERRM) 
     229        RETURNING * INTO output_record; 
    238230      RETURN output_record; 
    239231    ELSE 
    240       INSERT INTO test.results (name, module, ok, errcode, errmsg) 
    241         VALUES (testname, modulename, FALSE, SQLSTATE, SQLERRM) 
    242         RETURNING name, module, CASE WHEN ok=true THEN '[OK]' ELSE '[FAIL]' END, errcode, errmsg 
    243         INTO output_record; 
     232      INSERT INTO test.results (name, module, result, errcode, errmsg) 
     233        VALUES (testname, modulename, '[FAIL]', SQLSTATE, SQLERRM) 
     234        RETURNING * INTO output_record; 
    244235      RETURN output_record; 
    245236    END IF; 
     
    251242 
    252243 
    253 CREATE OR REPLACE FUNCTION test.run_module(modulename text) RETURNS SETOF test.suite_results AS $$ 
     244CREATE OR REPLACE FUNCTION test.run_module(modulename text) RETURNS SETOF test.results AS $$ 
    254245-- Runs all tests in the given module, stores in test.results, and returns results. 
    255246DECLARE 
    256247  testname        pg_proc.proname%TYPE; 
    257   output_record   test.suite_results%ROWTYPE; 
     248  output_record   test.results%ROWTYPE; 
    258249BEGIN 
    259250  FOR testname IN SELECT name FROM test.testnames WHERE module = modulename 
     
    266257 
    267258 
    268 CREATE OR REPLACE FUNCTION test.run_all() RETURNS SETOF test.suite_results AS $$ 
     259CREATE OR REPLACE FUNCTION test.run_all() RETURNS SETOF test.results AS $$ 
    269260-- Runs all known test functions, stores in test.results, and returns results. 
    270261DECLARE 
    271262  testname pg_proc.proname%TYPE; 
    272263  modulename text; 
    273   output_record test.suite_results%ROWTYPE; 
     264  output_record test.results%ROWTYPE; 
    274265BEGIN 
    275266  FOR modulename in SELECT DISTINCT module FROM test.testnames ORDER BY module ASC 
  • trunk/epic/test/test_asserts.sql

    r5 r9  
    2424  IF objname IS NULL THEN 
    2525    RAISE EXCEPTION 'assert_test_schema did not create a test.results table.'; 
    26   END IF; 
    27    
    28   -- assert_test_schema MUST create a 'test.suite_results' type 
    29   SELECT typname INTO objname FROM pg_type 
    30     WHERE typnamespace = nsoid AND typname = 'suite_results'; 
    31   IF objname IS NULL THEN 
    32     RAISE EXCEPTION 'assert_test_schema did not create a test.suite_results type.'; 
    3326  END IF; 
    3427