|
| 1 | +/* |
| 2 | +CI Test: Validate @help = 1 output for all procedures. |
| 3 | +Uses a temp table to track results across GO batches. |
| 4 | +Fails with RAISERROR if any proc errors on @help = 1. |
| 5 | +*/ |
| 6 | + |
| 7 | +SET NOCOUNT ON; |
| 8 | + |
| 9 | +CREATE TABLE #help_results (proc_name VARCHAR(100) NOT NULL, passed BIT NOT NULL); |
| 10 | +GO |
| 11 | + |
| 12 | +PRINT '========================================'; |
| 13 | +PRINT 'Testing @help = 1 for all procedures'; |
| 14 | +PRINT '========================================'; |
| 15 | +PRINT ''; |
| 16 | +GO |
| 17 | + |
| 18 | +/* sp_HealthParser */ |
| 19 | +BEGIN TRY |
| 20 | + EXEC dbo.sp_HealthParser @help = 1; |
| 21 | + INSERT #help_results VALUES ('sp_HealthParser', 1); |
| 22 | + PRINT 'PASS: sp_HealthParser @help = 1'; |
| 23 | +END TRY |
| 24 | +BEGIN CATCH |
| 25 | + INSERT #help_results VALUES ('sp_HealthParser', 0); |
| 26 | + PRINT 'FAIL: sp_HealthParser @help = 1 - ' + ERROR_MESSAGE(); |
| 27 | +END CATCH; |
| 28 | +GO |
| 29 | + |
| 30 | +/* sp_HumanEvents */ |
| 31 | +BEGIN TRY |
| 32 | + EXEC dbo.sp_HumanEvents @help = 1; |
| 33 | + INSERT #help_results VALUES ('sp_HumanEvents', 1); |
| 34 | + PRINT 'PASS: sp_HumanEvents @help = 1'; |
| 35 | +END TRY |
| 36 | +BEGIN CATCH |
| 37 | + INSERT #help_results VALUES ('sp_HumanEvents', 0); |
| 38 | + PRINT 'FAIL: sp_HumanEvents @help = 1 - ' + ERROR_MESSAGE(); |
| 39 | +END CATCH; |
| 40 | +GO |
| 41 | + |
| 42 | +/* sp_HumanEventsBlockViewer */ |
| 43 | +BEGIN TRY |
| 44 | + EXEC dbo.sp_HumanEventsBlockViewer @help = 1; |
| 45 | + INSERT #help_results VALUES ('sp_HumanEventsBlockViewer', 1); |
| 46 | + PRINT 'PASS: sp_HumanEventsBlockViewer @help = 1'; |
| 47 | +END TRY |
| 48 | +BEGIN CATCH |
| 49 | + INSERT #help_results VALUES ('sp_HumanEventsBlockViewer', 0); |
| 50 | + PRINT 'FAIL: sp_HumanEventsBlockViewer @help = 1 - ' + ERROR_MESSAGE(); |
| 51 | +END CATCH; |
| 52 | +GO |
| 53 | + |
| 54 | +/* sp_IndexCleanup */ |
| 55 | +BEGIN TRY |
| 56 | + EXEC dbo.sp_IndexCleanup @help = 1; |
| 57 | + INSERT #help_results VALUES ('sp_IndexCleanup', 1); |
| 58 | + PRINT 'PASS: sp_IndexCleanup @help = 1'; |
| 59 | +END TRY |
| 60 | +BEGIN CATCH |
| 61 | + INSERT #help_results VALUES ('sp_IndexCleanup', 0); |
| 62 | + PRINT 'FAIL: sp_IndexCleanup @help = 1 - ' + ERROR_MESSAGE(); |
| 63 | +END CATCH; |
| 64 | +GO |
| 65 | + |
| 66 | +/* sp_LogHunter */ |
| 67 | +BEGIN TRY |
| 68 | + EXEC dbo.sp_LogHunter @help = 1; |
| 69 | + INSERT #help_results VALUES ('sp_LogHunter', 1); |
| 70 | + PRINT 'PASS: sp_LogHunter @help = 1'; |
| 71 | +END TRY |
| 72 | +BEGIN CATCH |
| 73 | + INSERT #help_results VALUES ('sp_LogHunter', 0); |
| 74 | + PRINT 'FAIL: sp_LogHunter @help = 1 - ' + ERROR_MESSAGE(); |
| 75 | +END CATCH; |
| 76 | +GO |
| 77 | + |
| 78 | +/* sp_PerfCheck */ |
| 79 | +BEGIN TRY |
| 80 | + EXEC dbo.sp_PerfCheck @help = 1; |
| 81 | + INSERT #help_results VALUES ('sp_PerfCheck', 1); |
| 82 | + PRINT 'PASS: sp_PerfCheck @help = 1'; |
| 83 | +END TRY |
| 84 | +BEGIN CATCH |
| 85 | + INSERT #help_results VALUES ('sp_PerfCheck', 0); |
| 86 | + PRINT 'FAIL: sp_PerfCheck @help = 1 - ' + ERROR_MESSAGE(); |
| 87 | +END CATCH; |
| 88 | +GO |
| 89 | + |
| 90 | +/* sp_PressureDetector */ |
| 91 | +BEGIN TRY |
| 92 | + EXEC dbo.sp_PressureDetector @help = 1; |
| 93 | + INSERT #help_results VALUES ('sp_PressureDetector', 1); |
| 94 | + PRINT 'PASS: sp_PressureDetector @help = 1'; |
| 95 | +END TRY |
| 96 | +BEGIN CATCH |
| 97 | + INSERT #help_results VALUES ('sp_PressureDetector', 0); |
| 98 | + PRINT 'FAIL: sp_PressureDetector @help = 1 - ' + ERROR_MESSAGE(); |
| 99 | +END CATCH; |
| 100 | +GO |
| 101 | + |
| 102 | +/* sp_QueryReproBuilder */ |
| 103 | +BEGIN TRY |
| 104 | + EXEC dbo.sp_QueryReproBuilder @help = 1; |
| 105 | + INSERT #help_results VALUES ('sp_QueryReproBuilder', 1); |
| 106 | + PRINT 'PASS: sp_QueryReproBuilder @help = 1'; |
| 107 | +END TRY |
| 108 | +BEGIN CATCH |
| 109 | + INSERT #help_results VALUES ('sp_QueryReproBuilder', 0); |
| 110 | + PRINT 'FAIL: sp_QueryReproBuilder @help = 1 - ' + ERROR_MESSAGE(); |
| 111 | +END CATCH; |
| 112 | +GO |
| 113 | + |
| 114 | +/* sp_QuickieStore */ |
| 115 | +BEGIN TRY |
| 116 | + EXEC dbo.sp_QuickieStore @help = 1; |
| 117 | + INSERT #help_results VALUES ('sp_QuickieStore', 1); |
| 118 | + PRINT 'PASS: sp_QuickieStore @help = 1'; |
| 119 | +END TRY |
| 120 | +BEGIN CATCH |
| 121 | + INSERT #help_results VALUES ('sp_QuickieStore', 0); |
| 122 | + PRINT 'FAIL: sp_QuickieStore @help = 1 - ' + ERROR_MESSAGE(); |
| 123 | +END CATCH; |
| 124 | +GO |
| 125 | + |
| 126 | +/* Summary - fail the build if any test failed */ |
| 127 | +PRINT ''; |
| 128 | +PRINT '========================================'; |
| 129 | + |
| 130 | +DECLARE @failed int = (SELECT COUNT(*) FROM #help_results WHERE passed = 0); |
| 131 | +DECLARE @total int = (SELECT COUNT(*) FROM #help_results); |
| 132 | + |
| 133 | +PRINT 'Help output: ' + CONVERT(varchar(10), @total - @failed) + '/' + CONVERT(varchar(10), @total) + ' passed'; |
| 134 | + |
| 135 | +IF @failed > 0 |
| 136 | + RAISERROR('%d procedure(s) failed @help = 1', 16, 1, @failed); |
| 137 | +ELSE |
| 138 | + PRINT 'All procedures passed'; |
| 139 | + |
| 140 | +PRINT '========================================'; |
| 141 | + |
| 142 | +DROP TABLE #help_results; |
| 143 | +GO |
0 commit comments