< Summary - Igor Pro Universal Testing Framework

Information
Class: procedures.igortest-reporting-control
Assembly: procedures
File(s): /builds/mirror/igortest/procedures/igortest-reporting-control.ipf
Tag: 74147b3
Line coverage
82%
Covered lines: 100
Uncovered lines: 21
Coverable lines: 121
Total lines: 179
Line coverage: 82.6%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/builds/mirror/igortest/procedures/igortest-reporting-control.ipf

#LineLine coverage
 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.
 511static Function SetupTestRun()
 512  variable id
 13
 514  WAVE/T wvTestRun = IUTF_Reporting#GetTestRunWave()
 515  id = IUTF_Utils_Vector#AddRow(wvTestRun)
 16
 517  wvTestRun[id][%HOSTNAME] = "localhost"
 18#if (IgorVersion() >= 7.00)
 519  strswitch(IgorInfo(2))
 420    case "Windows":
 421      wvTestRun[id][%HOSTNAME] = GetEnvironmentVariable("COMPUTERNAME")
 422      break
 123    case "Macintosh":
 124      wvTestRun[id][%HOSTNAME] = GetEnvironmentVariable("HOSTNAME")
 125      break
 026    default:
 027      break
 528  endswitch
 529  wvTestRun[id][%USERNAME] = IgorInfo(7)
 30#endif
 531  wvTestRun[id][%NUM_ERROR]        = "0"
 532  wvTestRun[id][%NUM_SKIPPED]      = "0"
 533  wvTestRun[id][%NUM_TESTS]        = "0"
 534  wvTestRun[id][%NUM_ASSERT]       = "0"
 535  wvTestRun[id][%NUM_ASSERT_ERROR] = "0"
 536  wvTestRun[id][%SYSTEMINFO]       = IgorInfo(3)
 537  wvTestRun[id][%IGORINFO]         = IgorInfo(0)
 538  wvTestRun[id][%VERSION]          = IUTF_Basics#GetVersion()
 539  wvTestRun[id][%EXPERIMENT]       = IgorInfo(1)
 540  wvTestRun[id][%CHILD_START]      = "0"
 541  wvTestRun[id][%CHILD_END]        = "0"
 542End
 43
 44/// @brief Begin a new test run. This test run has to be initialized with SetupTestRun first.
 645static Function TestBegin()
 646  WAVE/T wvTestRun = IUTF_Reporting#GetTestRunWave()
 647  wvTestRun[%CURRENT][%STARTTIME] = IUTF_Reporting#GetTimeString()
 648End
 49
 50/// @brief End the current test run.
 551static Function TestEnd()
 552  WAVE/T wvTestRun = IUTF_Reporting#GetTestRunWave()
 553  wvTestRun[%CURRENT][%ENDTIME] = IUTF_Reporting#GetTimeString()
 554End
 55
 56/// @brief Begin a new test suite.
 57///
 58/// @param testSuite  The name of the test suite.
 3359static Function TestSuiteBegin(testSuite)
 60  string testSuite
 61
 3362  variable id
 63
 3364  WAVE/T wvSuite = IUTF_Reporting#GetTestSuiteWave()
 3365  id = IUTF_Utils_Vector#AddRow(wvSuite)
 66
 3367  wvSuite[id][%PROCEDURENAME]    = testSuite
 3368  wvSuite[id][%STARTTIME]        = IUTF_Reporting#GetTimeString()
 3369  wvSuite[id][%NUM_ERROR]        = "0"
 3370  wvSuite[id][%NUM_SKIPPED]      = "0"
 3371  wvSuite[id][%NUM_TESTS]        = "0"
 3372  wvSuite[id][%NUM_ASSERT]       = "0"
 3373  wvSuite[id][%NUM_ASSERT_ERROR] = "0"
 74
 3375  WAVE/T wvTestCase = IUTF_Reporting#GetTestCaseWave()
 3376  IUTF_Reporting#UpdateChildRange(wvSuite, wvTestCase, init = 1)
 77
 3378  WAVE/T wvTestRun = IUTF_Reporting#GetTestRunWave()
 3379  IUTF_Reporting#UpdateChildRange(wvTestRun, wvSuite)
 3380End
 81
 82/// @brief End the current test suite
 3283static Function TestSuiteEnd()
 3284  WAVE/T wvTestSuite = IUTF_Reporting#GetTestSuiteWave()
 3285  wvTestSuite[%CURRENT][%ENDTIME] = IUTF_Reporting#GetTimeString()
 86
 3287  WAVE/T wvTestRun = IUTF_Reporting#GetTestRunWave()
 3288  wvTestRun[%CURRENT][%NUM_ASSERT]       = num2istr(str2num(wvTestRun[%CURRENT][%NUM_ASSERT]) + str2num(wvTestSuite[%CUR
 3289  wvTestRun[%CURRENT][%NUM_ASSERT_ERROR] = num2istr(str2num(wvTestRun[%CURRENT][%NUM_ASSERT_ERROR]) + str2num(wvTestSuit
 3290  wvTestRun[%CURRENT][%NUM_ERROR]        = num2istr(str2num(wvTestRun[%CURRENT][%NUM_ERROR]) + str2num(wvTestSuite[%CURR
 3291  wvTestRun[%CURRENT][%NUM_SKIPPED]      = num2istr(str2num(wvTestRun[%CURRENT][%NUM_SKIPPED]) + str2num(wvTestSuite[%CU
 3292End
 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.
 8599static Function TestCaseBegin(testCase, skip)
 100  string   testCase
 101  variable skip
 102
 85103  variable testId
 104
 85105  WAVE/T wvTestCase = IUTF_Reporting#GetTestCaseWave()
 85106  testId = IUTF_Utils_Vector#AddRow(wvTestCase)
 107
 85108  wvTestCase[testId][%NAME]             = testCase
 85109  wvTestCase[testId][%STARTTIME]        = IUTF_Reporting#GetTimeString()
 85110  wvTestCase[testId][%NUM_ASSERT]       = "0"
 85111  wvTestCase[testId][%NUM_ASSERT_ERROR] = "0"
 85112  wvTestCase[testId][%STATUS]           = IUTF_STATUS_RUNNING
 113
 85114  WAVE/T wvAssertion = IUTF_Reporting#GetTestAssertionWave()
 85115  IUTF_Reporting#UpdateChildRange(wvTestCase, wvAssertion, init = 1)
 116
 85117  WAVE/T wvSuite = IUTF_Reporting#GetTestSuiteWave()
 85118  IUTF_Reporting#UpdateChildRange(wvSuite, wvTestCase)
 85119  wvSuite[%CURRENT][%NUM_TESTS] = num2istr(str2num(wvSuite[%CURRENT][%NUM_TESTS]) + 1)
 120
 85121  WAVE/T wvTestRun = IUTF_Reporting#GetTestRunWave()
 85122  wvTestRun[%CURRENT][%NUM_TESTS] = num2istr(str2num(wvTestRun[%CURRENT][%NUM_TESTS]) + 1)
 123
 85124  if(skip)
 0125    wvTestCase[%CURRENT][%STATUS]    = IUTF_STATUS_SKIP
 0126    wvTestCase[%CURRENT][%ENDTIME]   = "0"
 0127    wvTestCase[%CURRENT][%STARTTIME] = "0"
 85128  else
 85129    Notebook HistoryCarbonCopy, getData=1
 85130    wvTestCase[%CURRENT][%STDOUT] = S_Value
 85131  endif
 85132End
 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.
 84138static Function TestCaseEnd(endTime)
 139  string endTime
 140
 84141  string name, msg
 142
 84143  WAVE/T wvTestCase = IUTF_Reporting#GetTestCaseWave()
 84144  wvTestCase[%CURRENT][%ENDTIME] = endTime
 145
 84146  if(!CmpStr(wvTestCase[%CURRENT][%STATUS], IUTF_STATUS_UNKNOWN))
 0147    name = wvTestCase[%CURRENT][%NAME]
 0148    sprintf msg, "Bug: Test case \"%s\" has an unknown state after it was running.", name
 0149    IUTF_Reporting#TestCaseFail(msg)
 84150  endif
 84151  strswitch(wvTestCase[%CURRENT][%STATUS])
 84152    case IUTF_STATUS_RUNNING:
 84153      wvTestCase[%CURRENT][%STATUS] = IUTF_STATUS_SUCCESS
 84154      break
 0155    case IUTF_STATUS_ERROR:
 0156    case IUTF_STATUS_FAIL:
 0157      WAVE/T wvTestSuite = IUTF_Reporting#GetTestSuiteWave()
 0158      wvTestSuite[%CURRENT][%NUM_ERROR] = num2istr(str2num(wvTestSuite[%CURRENT][%NUM_ERROR]) + 1)
 0159      break
 0160    case IUTF_STATUS_SKIP:
 0161      WAVE/T wvTestSuite = IUTF_Reporting#GetTestSuiteWave()
 0162      wvTestSuite[%CURRENT][%NUM_SKIPPED] = num2istr(str2num(wvTestSuite[%CURRENT][%NUM_SKIPPED]) + 1)
 0163      break
 164    // IUTF_STATUS_RETRY is not expected at this point so we use the default case
 0165    default:
 0166      sprintf msg, "test status \"%s\" is not supported for test case \"%s\".", wvTestCase[%CURRENT][%STATUS], name
 0167      IUTF_Reporting#ReportError(msg)
 0168      break
 84169  endswitch
 170
 84171  Notebook HistoryCarbonCopy, getData=1
 84172  wvTestCase[%CURRENT][%STDOUT] = S_Value[strlen(wvTestCase[%CURRENT][%STDOUT]), Inf]
 173
 84174  WAVE/T wvTestSuite = IUTF_Reporting#GetTestSuiteWave()
 84175  wvTestSuite[%CURRENT][%STDOUT]          += wvTestCase[%CURRENT][%STDOUT]
 84176  wvTestSuite[%CURRENT][%STDERR]          += wvTestCase[%CURRENT][%STDERR]
 84177  wvTestSuite[%CURRENT][%NUM_ASSERT]       = num2istr(str2num(wvTestSuite[%CURRENT][%NUM_ASSERT]) + str2num(wvTestCase[%
 84178  wvTestSuite[%CURRENT][%NUM_ASSERT_ERROR] = num2istr(str2num(wvTestSuite[%CURRENT][%NUM_ASSERT_ERROR]) + str2num(wvTest
 84179End