-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathUnitTest.Discover.pq
67 lines (64 loc) · 2 KB
/
UnitTest.Discover.pq
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
67
/**
Discover and run tests from all local sources.
Represent results as a table either grouped by status (compact_output = true)
or detailed with one row per each test (compact_output = false).
**/
(optional compact_output as nullable logical) =>
let
/* Default behavior is not yet decided upon and may be changed in future */
Compact = if compact_output <> null then compact_output else true,
Library = LibPQ(),
Config = LibPQ("UnitTest.Constants"),
UnitTest.Run = LibPQ("UnitTest.Run"),
SuitesFilter = Table.SelectRows(
Table.AddColumn(
Record.ToTable(Library),
"SuiteVersion",
each
try Text.From(
Record.Field(
Value.Metadata([Value]),
Config[Suite.MetaField]
)
) otherwise
null
),
each [SuiteVersion] <> null
),
Suites = Table.RenameColumns(
SuitesFilter,
List.Zip({
Table.ColumnNames(SuitesFilter),
{"Suite", "Object", "Version"}
})
),
SuiteRunners = Record.FromList(
List.Transform(
Record.FieldValues(Config[Suite.Runners]),
each LibPQ(_)
),
Record.FieldNames(Config[Suite.Runners])
),
Run = Table.AddColumn(
Suites,
"Results",
each Record.Field(SuiteRunners, [Version])([Object])
),
Expanded = Table.ExpandTableColumn(
Table.RemoveColumns(Run, "Version"),
"Results",
Table.ColumnNames(Run[Results]{0})
),
LongResults = Table.RemoveColumns(Expanded, {"Object"}),
ShortResults = Table.Group(
LongResults,
{"Status"},
{
{"Count", each Table.RowCount(_), type number},
{"Details", each _, type table}
}
),
ShortResultsSorted = Table.Sort(ShortResults, {{"Status", Order.Ascending}}),
Return = if Compact then ShortResultsSorted else LongResults
in
Return