Scoop API

scoop:scoop.test:0.1.0

src/execution/selection.scoop

Selected production source · src/execution/selection.scoop

1package scoop.test.execution
3// Full argv starts with the program path, then the command's selection marker.
4// A directly launched test executable defaults to its non-ignored cases.
5/**
6 * Interprets the generated runner's case selection arguments and ignored-case policy for one
7 * stable case index.
8 */
9public fun isTestSelected(
10 arguments: Array<String>, caseIndex: String, ignored: Boolean, caseName: String = ""
11): Boolean {
12 if (arguments.size <= 1L) { return !ignored }
13 if (arguments[1L] == "--scoop-test-filter" || arguments[1L] == "--scoop-test-filter-ignored") {
14 if (arguments.size != 3L) return false
15 val selectIgnored = arguments[1L] == "--scoop-test-filter-ignored"
16 if (ignored != selectIgnored) return false
17 val name = caseName.toCharArray()
18 val filter = arguments[2L].toCharArray()
19 var start = 0L
20 while (start <= name.size - filter.size) {
21 var index = 0L
22 while (index < filter.size && name[start + index] == filter[index]) index += 1L
23 if (index == filter.size) return true
24 start += 1L
25 }
26 return false
27 }
28 if (arguments[1L] == "--scoop-test-child") {
29 return arguments.size == 3L && arguments[2L] == caseIndex
30 }
31 val marker = if (arguments[1L] == "--scoop-test-isolate-all") 2L else 1L
32 if (arguments.size <= marker || arguments[marker] != "--scoop-test-cases") return false
33 var index = marker + 1L
34 while (index < arguments.size) {
35 if (arguments[index] == caseIndex) { return true }
36 index += 1L
37 }
38 return false