| | 1 | | #pragma rtGlobals=3 |
| | 2 | | #pragma TextEncoding="UTF-8" |
| | 3 | | #pragma rtFunctionErrors=1 |
| | 4 | | #pragma version=1.10 |
| | 5 | | #pragma ModuleName=IUTF_Reporting_Control |
| | 6 | |
|
| | 7 | | // This procedure file combines functions that control the output like test suite begin/end or test |
| | 8 | | // case begin/end. |
| | 9 | |
|
| | 10 | | /// @brief Setup the test run result wave with data. |
| 5 | 11 | | static Function SetupTestRun() |
| 5 | 12 | | variable id |
| | 13 | |
|
| 5 | 14 | | WAVE/T wvTestRun = IUTF_Reporting#GetTestRunWave() |
| 5 | 15 | | id = IUTF_Utils_Vector#AddRow(wvTestRun) |
| | 16 | |
|
| 5 | 17 | | wvTestRun[id][%HOSTNAME] = "localhost" |
| | 18 | | #if (IgorVersion() >= 7.00) |
| 5 | 19 | | strswitch(IgorInfo(2)) |
| 4 | 20 | | case "Windows": |
| 4 | 21 | | wvTestRun[id][%HOSTNAME] = GetEnvironmentVariable("COMPUTERNAME") |
| 4 | 22 | | break |
| 1 | 23 | | case "Macintosh": |
| 1 | 24 | | wvTestRun[id][%HOSTNAME] = GetEnvironmentVariable("HOSTNAME") |
| 1 | 25 | | break |
| 0 | 26 | | default: |
| 0 | 27 | | break |
| 5 | 28 | | endswitch |
| 5 | 29 | | wvTestRun[id][%USERNAME] = IgorInfo(7) |
| | 30 | | #endif |
| 5 | 31 | | wvTestRun[id][%NUM_ERROR] = "0" |
| 5 | 32 | | wvTestRun[id][%NUM_SKIPPED] = "0" |
| 5 | 33 | | wvTestRun[id][%NUM_TESTS] = "0" |
| 5 | 34 | | wvTestRun[id][%NUM_ASSERT] = "0" |
| 5 | 35 | | wvTestRun[id][%NUM_ASSERT_ERROR] = "0" |
| 5 | 36 | | wvTestRun[id][%SYSTEMINFO] = IgorInfo(3) |
| 5 | 37 | | wvTestRun[id][%IGORINFO] = IgorInfo(0) |
| 5 | 38 | | wvTestRun[id][%VERSION] = IUTF_Basics#GetVersion() |
| 5 | 39 | | wvTestRun[id][%EXPERIMENT] = IgorInfo(1) |
| 5 | 40 | | wvTestRun[id][%CHILD_START] = "0" |
| 5 | 41 | | wvTestRun[id][%CHILD_END] = "0" |
| 5 | 42 | | End |
| | 43 | |
|
| | 44 | | /// @brief Begin a new test run. This test run has to be initialized with SetupTestRun first. |
| 6 | 45 | | static Function TestBegin() |
| 6 | 46 | | WAVE/T wvTestRun = IUTF_Reporting#GetTestRunWave() |
| 6 | 47 | | wvTestRun[%CURRENT][%STARTTIME] = IUTF_Reporting#GetTimeString() |
| 6 | 48 | | End |
| | 49 | |
|
| | 50 | | /// @brief End the current test run. |
| 5 | 51 | | static Function TestEnd() |
| 5 | 52 | | WAVE/T wvTestRun = IUTF_Reporting#GetTestRunWave() |
| 5 | 53 | | wvTestRun[%CURRENT][%ENDTIME] = IUTF_Reporting#GetTimeString() |
| 5 | 54 | | End |
| | 55 | |
|
| | 56 | | /// @brief Begin a new test suite. |
| | 57 | | /// |
| | 58 | | /// @param testSuite The name of the test suite. |
| 33 | 59 | | static Function TestSuiteBegin(testSuite) |
| | 60 | | string testSuite |
| | 61 | |
|
| 33 | 62 | | variable id |
| | 63 | |
|
| 33 | 64 | | WAVE/T wvSuite = IUTF_Reporting#GetTestSuiteWave() |
| 33 | 65 | | id = IUTF_Utils_Vector#AddRow(wvSuite) |
| | 66 | |
|
| 33 | 67 | | wvSuite[id][%PROCEDURENAME] = testSuite |
| 33 | 68 | | wvSuite[id][%STARTTIME] = IUTF_Reporting#GetTimeString() |
| 33 | 69 | | wvSuite[id][%NUM_ERROR] = "0" |
| 33 | 70 | | wvSuite[id][%NUM_SKIPPED] = "0" |
| 33 | 71 | | wvSuite[id][%NUM_TESTS] = "0" |
| 33 | 72 | | wvSuite[id][%NUM_ASSERT] = "0" |
| 33 | 73 | | wvSuite[id][%NUM_ASSERT_ERROR] = "0" |
| | 74 | |
|
| 33 | 75 | | WAVE/T wvTestCase = IUTF_Reporting#GetTestCaseWave() |
| 33 | 76 | | IUTF_Reporting#UpdateChildRange(wvSuite, wvTestCase, init = 1) |
| | 77 | |
|
| 33 | 78 | | WAVE/T wvTestRun = IUTF_Reporting#GetTestRunWave() |
| 33 | 79 | | IUTF_Reporting#UpdateChildRange(wvTestRun, wvSuite) |
| 33 | 80 | | End |
| | 81 | |
|
| | 82 | | /// @brief End the current test suite |
| 32 | 83 | | static Function TestSuiteEnd() |
| 32 | 84 | | WAVE/T wvTestSuite = IUTF_Reporting#GetTestSuiteWave() |
| 32 | 85 | | wvTestSuite[%CURRENT][%ENDTIME] = IUTF_Reporting#GetTimeString() |
| | 86 | |
|
| 32 | 87 | | WAVE/T wvTestRun = IUTF_Reporting#GetTestRunWave() |
| 32 | 88 | | wvTestRun[%CURRENT][%NUM_ASSERT] = num2istr(str2num(wvTestRun[%CURRENT][%NUM_ASSERT]) + str2num(wvTestSuite[%CUR |
| 32 | 89 | | wvTestRun[%CURRENT][%NUM_ASSERT_ERROR] = num2istr(str2num(wvTestRun[%CURRENT][%NUM_ASSERT_ERROR]) + str2num(wvTestSuit |
| 32 | 90 | | wvTestRun[%CURRENT][%NUM_ERROR] = num2istr(str2num(wvTestRun[%CURRENT][%NUM_ERROR]) + str2num(wvTestSuite[%CURR |
| 32 | 91 | | wvTestRun[%CURRENT][%NUM_SKIPPED] = num2istr(str2num(wvTestRun[%CURRENT][%NUM_SKIPPED]) + str2num(wvTestSuite[%CU |
| 32 | 92 | | End |
| | 93 | |
|
| | 94 | | /// @brief Begin a new test case. |
| | 95 | | /// |
| | 96 | | /// @param testCase The name of the test case |
| | 97 | | /// @param skip A value different to zero will mark this test case as skipped. No TestCaseEnd() |
| | 98 | | /// call is required. Setting this to zero will start the test case normally. |
| 85 | 99 | | static Function TestCaseBegin(testCase, skip) |
| | 100 | | string testCase |
| | 101 | | variable skip |
| | 102 | |
|
| 85 | 103 | | variable testId |
| | 104 | |
|
| 85 | 105 | | WAVE/T wvTestCase = IUTF_Reporting#GetTestCaseWave() |
| 85 | 106 | | testId = IUTF_Utils_Vector#AddRow(wvTestCase) |
| | 107 | |
|
| 85 | 108 | | wvTestCase[testId][%NAME] = testCase |
| 85 | 109 | | wvTestCase[testId][%STARTTIME] = IUTF_Reporting#GetTimeString() |
| 85 | 110 | | wvTestCase[testId][%NUM_ASSERT] = "0" |
| 85 | 111 | | wvTestCase[testId][%NUM_ASSERT_ERROR] = "0" |
| 85 | 112 | | wvTestCase[testId][%STATUS] = IUTF_STATUS_RUNNING |
| | 113 | |
|
| 85 | 114 | | WAVE/T wvAssertion = IUTF_Reporting#GetTestAssertionWave() |
| 85 | 115 | | IUTF_Reporting#UpdateChildRange(wvTestCase, wvAssertion, init = 1) |
| | 116 | |
|
| 85 | 117 | | WAVE/T wvSuite = IUTF_Reporting#GetTestSuiteWave() |
| 85 | 118 | | IUTF_Reporting#UpdateChildRange(wvSuite, wvTestCase) |
| 85 | 119 | | wvSuite[%CURRENT][%NUM_TESTS] = num2istr(str2num(wvSuite[%CURRENT][%NUM_TESTS]) + 1) |
| | 120 | |
|
| 85 | 121 | | WAVE/T wvTestRun = IUTF_Reporting#GetTestRunWave() |
| 85 | 122 | | wvTestRun[%CURRENT][%NUM_TESTS] = num2istr(str2num(wvTestRun[%CURRENT][%NUM_TESTS]) + 1) |
| | 123 | |
|
| 85 | 124 | | if(skip) |
| 0 | 125 | | wvTestCase[%CURRENT][%STATUS] = IUTF_STATUS_SKIP |
| 0 | 126 | | wvTestCase[%CURRENT][%ENDTIME] = "0" |
| 0 | 127 | | wvTestCase[%CURRENT][%STARTTIME] = "0" |
| 85 | 128 | | else |
| 85 | 129 | | Notebook HistoryCarbonCopy, getData=1 |
| 85 | 130 | | wvTestCase[%CURRENT][%STDOUT] = S_Value |
| 85 | 131 | | endif |
| 85 | 132 | | End |
| | 133 | |
|
| | 134 | | /// @brief End the current test case |
| | 135 | | /// |
| | 136 | | /// @param endTime The end time when this test case finished. Use IUTF_Reporting#GetTimeString() to |
| | 137 | | /// get the value for this parameter. |
| 84 | 138 | | static Function TestCaseEnd(endTime) |
| | 139 | | string endTime |
| | 140 | |
|
| 84 | 141 | | string name, msg |
| | 142 | |
|
| 84 | 143 | | WAVE/T wvTestCase = IUTF_Reporting#GetTestCaseWave() |
| 84 | 144 | | wvTestCase[%CURRENT][%ENDTIME] = endTime |
| | 145 | |
|
| 84 | 146 | | if(!CmpStr(wvTestCase[%CURRENT][%STATUS], IUTF_STATUS_UNKNOWN)) |
| 0 | 147 | | name = wvTestCase[%CURRENT][%NAME] |
| 0 | 148 | | sprintf msg, "Bug: Test case \"%s\" has an unknown state after it was running.", name |
| 0 | 149 | | IUTF_Reporting#TestCaseFail(msg) |
| 84 | 150 | | endif |
| 84 | 151 | | strswitch(wvTestCase[%CURRENT][%STATUS]) |
| 84 | 152 | | case IUTF_STATUS_RUNNING: |
| 84 | 153 | | wvTestCase[%CURRENT][%STATUS] = IUTF_STATUS_SUCCESS |
| 84 | 154 | | break |
| 0 | 155 | | case IUTF_STATUS_ERROR: |
| 0 | 156 | | case IUTF_STATUS_FAIL: |
| 0 | 157 | | WAVE/T wvTestSuite = IUTF_Reporting#GetTestSuiteWave() |
| 0 | 158 | | wvTestSuite[%CURRENT][%NUM_ERROR] = num2istr(str2num(wvTestSuite[%CURRENT][%NUM_ERROR]) + 1) |
| 0 | 159 | | break |
| 0 | 160 | | case IUTF_STATUS_SKIP: |
| 0 | 161 | | WAVE/T wvTestSuite = IUTF_Reporting#GetTestSuiteWave() |
| 0 | 162 | | wvTestSuite[%CURRENT][%NUM_SKIPPED] = num2istr(str2num(wvTestSuite[%CURRENT][%NUM_SKIPPED]) + 1) |
| 0 | 163 | | break |
| | 164 | | // IUTF_STATUS_RETRY is not expected at this point so we use the default case |
| 0 | 165 | | default: |
| 0 | 166 | | sprintf msg, "test status \"%s\" is not supported for test case \"%s\".", wvTestCase[%CURRENT][%STATUS], name |
| 0 | 167 | | IUTF_Reporting#ReportError(msg) |
| 0 | 168 | | break |
| 84 | 169 | | endswitch |
| | 170 | |
|
| 84 | 171 | | Notebook HistoryCarbonCopy, getData=1 |
| 84 | 172 | | wvTestCase[%CURRENT][%STDOUT] = S_Value[strlen(wvTestCase[%CURRENT][%STDOUT]), Inf] |
| | 173 | |
|
| 84 | 174 | | WAVE/T wvTestSuite = IUTF_Reporting#GetTestSuiteWave() |
| 84 | 175 | | wvTestSuite[%CURRENT][%STDOUT] += wvTestCase[%CURRENT][%STDOUT] |
| 84 | 176 | | wvTestSuite[%CURRENT][%STDERR] += wvTestCase[%CURRENT][%STDERR] |
| 84 | 177 | | wvTestSuite[%CURRENT][%NUM_ASSERT] = num2istr(str2num(wvTestSuite[%CURRENT][%NUM_ASSERT]) + str2num(wvTestCase[% |
| 84 | 178 | | wvTestSuite[%CURRENT][%NUM_ASSERT_ERROR] = num2istr(str2num(wvTestSuite[%CURRENT][%NUM_ASSERT_ERROR]) + str2num(wvTest |
| 84 | 179 | | End |