-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseManager.cls
More file actions
66 lines (60 loc) · 2.58 KB
/
BaseManager.cls
File metadata and controls
66 lines (60 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/// Helper superclass for the testing managers we use.
/// Must collate ahead of its subclasses, so it is already available on the server
/// when they are copied there by a directory copy.
Class vscode.dc.testingmanager.BaseManager [ Abstract ]
{
/// Keep this in sync with the version property in package.json
Parameter VERSION As STRING = "2.0.3";
Property tmMethodMap As %String [ MultiDimensional, Private ];
Method tmMapOneFile(file As %String) [ Private ]
{
Kill ..tmMethodMap(file)
Set tFlags=+..UserParam # 2 * 16 // Bit 0 f UserParam indicates we must get udl-multiline format (since Atelier API v4)
Set tSC=##class(%Atelier.v1.Utils.TextServices).GetTextAsArray(file,tFlags,.tTextArray)
//TODO: use the text array to create a tag-to-linenumber map
For lineNumber=1:1:+$Get(tTextArray(0)) {
Set line=$Get(tTextArray(lineNumber))
Set keyword=$Piece(line," ",1)
If keyword'="Method",keyword'="ClassMethod" Continue
Set tag=$Piece($Piece(line," ",2),"(",1)
// Take account of multi-line method format
While ("{"'[$Get(tTextArray(lineNumber+1))) {
Set lineNumber=lineNumber+1
}
Set ..tmMethodMap(file,tag)=lineNumber
}
// Note linecount as an indicator we've indexed this file, even if we found no methods
Set ..tmMethodMap(file)=+$Get(tTextArray(0))
}
/// Copied from %UnitTest.Manager and enhanced to append location information
/// to some log messages.
Method LogAssert(success, action, description, extra, location)
{
Set testsuite=i%TheStack(i%TheStack,"suite")
Set testcase=i%TheStack(i%TheStack,"case")
Set testmethod=i%TheStack(i%TheStack,"method")
If testmethod="" Quit
Do LogAssert^%SYS.UNITTEST(..OriginNS,..ResultId,testsuite,testcase,testmethod,success,action,description,$GET(location))
// Convert location to +offset^file if it is a type of assertion outcome we want to display inline
If success'=1,$Get(location)'="" {
Set file=$Piece(location,"^",2)
Set tagOffset=$Piece(location,"^",1)
Set offset=$Piece(tagOffset,"+",2)
Set tag=$Piece(tagOffset,"+",1)
If (tag'="") {
// Create a tag-to-linenumber map for file if we don't have one already
If '$Data(..tmMethodMap(file)) Do ..tmMapOneFile(file)
// Use it to compute what to add to the offset to get an absolute line number
Set tagLineNumber=$Get(..tmMethodMap(file,tag))
Set location="+"_(offset+tagLineNumber)_"^"_file
}
}
Set line=action_":"_description_" ("_..GetTestState(success)_")"
if success'=1 Set line = line_"@"_location
If 'success,..Display["error" {
Do ..PrintErrorLine(line,.extra)
} Else {
Do ..PrintLine(line,4)
}
}
}