-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinstall_unit_tests.sql
88 lines (73 loc) · 2.39 KB
/
install_unit_tests.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
--Purpose: Install unit tests for PLSQL_LEXER.
--How to run:
-- alter session set current_schema=&schema_name;
-- @install_unit_tests
--#1: Stop the script at first error, make the installation less noisy.
whenever sqlerror exit failure
whenever oserror exit failure
set feedback off
--#2: Installation banner
prompt
prompt ======================================
prompt = PLSQL_LEXER Unit Test Installation =
prompt ======================================
prompt
--#3: Install packages.
prompt Installing packages...
start tests/unit_tests.spc
start tests/statement_classifier_test.plsql
start tests/statement_feedback_test.plsql
start tests/statement_splitter_test.plsql
start tests/statement_terminator_test.plsql
start tests/plsql_lexer_test.plsql
start tests/misplaced_hints_test.plsql
--Separate spec and body because of circular dependency.
start tests/unit_tests.bdy
--#4: Verify installation.
prompt Verifying installation...
--Display all invalid objects.
column owner format a30;
column object_name format a30;
column object_type format a13;
select owner, object_name, object_type
from all_objects
where object_name in ('PLSQL_LEXER_TEST', 'STATEMENT_CLASSIFIER_TEST', 'STATEMENT_FEEDBACK_TEST',
'STATEMENT_SPLITTER_TEST', 'STATEMENT_TERMINATOR_TEST', 'UNIT_TESTS', 'MISPLACED_HINTS_TEST')
and owner = sys_context('userenv', 'current_schema')
and status <> 'VALID';
--Raise error if any packages are invalid.
--(Because compilation errors may be "warnings" that won't fail the script.)
declare
v_count number;
begin
select count(*)
into v_count
from all_objects
where object_name in ('PLSQL_LEXER_TEST', 'STATEMENT_CLASSIFIER_TEST', 'STATEMENT_CLASSIFIER_TEST',
'STATEMENT_SPLITTER_TEST', 'STATEMENT_TERMINATOR_TEST', 'PLSQL_LEXER_TEST', 'MISPLACED_HINTS_TEST')
and owner = sys_context('userenv', 'current_schema')
and status <> 'VALID';
if v_count >= 1 then
raise_application_error(-20000, 'Installation failed, the above objects '||
'are invalid.');
end if;
end;
/
--#5: Run unit tests and print success message.
prompt Running unit tests, this may take a minute...
set serveroutput on
set linesize 1000
begin
unit_tests.run_static_tests;
end;
/
prompt
prompt
prompt
prompt
prompt Unit test installation successful.
prompt (But do not trust any packages with a FAIL message above.)
--#6: Return SQL*Plus to normal environment.
whenever sqlerror continue
whenever oserror continue
set feedback on