|
| 1 | +/// Helper superclass for the testing managers we use. |
| 2 | +Class vscode.dc.testingmanager.BaseManager [ Abstract ] |
| 3 | +{ |
| 4 | + |
| 5 | +Property bmMethodMap As %String [ MultiDimensional, Private ]; |
| 6 | + |
| 7 | +Method bmMapOneFile(file As %String) [ Private ] |
| 8 | +{ |
| 9 | + Kill ..bmMethodMap(file) |
| 10 | + Set tFlags=+..UserParam # 2 * 16 // Bit 0 f UserParam indicates we must get udl-multiline format (since Atelier API v4) |
| 11 | + Set tSC=##class(%Atelier.v1.Utils.TextServices).GetTextAsArray(file,tFlags,.tTextArray) |
| 12 | + //TODO: use the text array to create a tag-to-linenumber map |
| 13 | + For lineNumber=1:1:+$Get(tTextArray(0)) { |
| 14 | + Set line=$Get(tTextArray(lineNumber)) |
| 15 | + Set keyword=$Piece(line," ",1) |
| 16 | + If keyword'="Method",keyword'="ClassMethod" Continue |
| 17 | + Set tag=$Piece($Piece(line," ",2),"(",1) |
| 18 | + // Take account of multi-line method format |
| 19 | + While ("{"'[$Get(tTextArray(lineNumber+1))) { |
| 20 | + Set lineNumber=lineNumber+1 |
| 21 | + } |
| 22 | + Set ..bmMethodMap(file,tag)=lineNumber |
| 23 | + } |
| 24 | + // Note linecount as an indicator we've indexed this file, even if we found no methods |
| 25 | + Set ..bmMethodMap(file)=+$Get(tTextArray(0)) |
| 26 | +} |
| 27 | + |
| 28 | +/// Copied from %UnitTest.Manager and enhanced to append location information |
| 29 | +/// to some log messages. |
| 30 | +Method LogAssert(success, action, description, extra, location) |
| 31 | +{ |
| 32 | + Set testsuite=i%TheStack(i%TheStack,"suite") |
| 33 | + Set testcase=i%TheStack(i%TheStack,"case") |
| 34 | + Set testmethod=i%TheStack(i%TheStack,"method") |
| 35 | + If testmethod="" Quit |
| 36 | + Do LogAssert^%SYS.UNITTEST(..OriginNS,..ResultId,testsuite,testcase,testmethod,success,action,description,$GET(location)) |
| 37 | + |
| 38 | + // Convert location to +offset^file if it is a type of assertion outcome we want to display inline |
| 39 | + If success'=1,$Get(location)'="" { |
| 40 | + Set file=$Piece(location,"^",2) |
| 41 | + Set tagOffset=$Piece(location,"^",1) |
| 42 | + Set offset=$Piece(tagOffset,"+",2) |
| 43 | + Set tag=$Piece(tagOffset,"+",1) |
| 44 | + If (tag'="") { |
| 45 | + // Create a tag-to-linenumber map for file if we don't have one already |
| 46 | + If '$Data(..bmMethodMap(file)) Do ..bmMapOneFile(file) |
| 47 | + // Use it to compute what to add to the offset to get an absolute line number |
| 48 | + Set tagLineNumber=$Get(..bmMethodMap(file,tag)) |
| 49 | + Set location="+"_(offset+tagLineNumber)_"^"_file |
| 50 | + } |
| 51 | + } |
| 52 | + Set line=action_":"_description_" ("_..GetTestState(success)_")" |
| 53 | + if success'=1 Set line = line_"@"_location |
| 54 | + If 'success,..Display["error" { |
| 55 | + Do ..PrintErrorLine(line,.extra) |
| 56 | + } Else { |
| 57 | + Do ..PrintLine(line,4) |
| 58 | + } |
| 59 | +} |
| 60 | + |
| 61 | +} |
0 commit comments