byte-physics / igortest

Igor Pro Universal Testing Framework
https://docs.byte-physics.de/igor-unit-testing-framework/
BSD 3-Clause "New" or "Revised" License
7 stars 2 forks source link

Get tracing running with independent modules #425

Closed Garados007 closed 1 year ago

Garados007 commented 1 year ago

Tracing is not easy to achieve with independent modules because they are some limitations in Igor. The problem is that Igor copies each igortest-* file into the IM and removes the connection to the local file doing this. Instrumenting afterwards in ProcGlobal doesn't change the igortest-* [IM] files and instrumenting in the IM doesn't work because igortest-* [IM] are no longer standalone procedures.

But there is a trick to enable tracing in IM:

  1. We need to do instrumentation in ProcGlobal first. As we need to know when instrumentation is finished we can do this with a simple RunTest() call that instruments our files and calls a single test case.
  2. The test case includes our IM file with Execute/P "INSERTINCLUDE \"filename\"". It is important that this file wasn't loaded before!
  3. The test case also calls Execute/P "SetIgorOption IndependentModuleDev=1" to enable IUTF in IM and Execute/P "COMPILEPROCEDURES " to ensure that the IM file is loaded.
  4. The IM file contains a TEST_END_OVERRIDE which is needed in step 7.
  5. Afterwards the test case calls Execute/P "IM#RunTest(... without tracing ...)"
  6. The single test case finishes and Igor executes the operation queue and starts the IM#RunTest() run with instrumented igortest-* [IM] files.
  7. The TEST_END_OVERRIDE [IM] calls IUTF_Tracing_Cobertura#PrintReport(coberturaSource, coberturaOut)

These are the minimal steps to allow tracing in IMs and generating Cobertura. If Cobertura isn't needed the user can skip step 4 and 7. The user can also introduce more steps to make the calls cleaner.

I got a proof of concept running that will be used to test the solution for #6. I need to cleanup the files and link the commit here later.