scoop:scoop.test:0.1.0
src/execution/selection.scoop
Selected production source · src/execution/selection.scoop
1
package scoop.test.execution3
// 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 one7
* stable case index.8
*/9
public 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 false15
val selectIgnored = arguments[1L] == "--scoop-test-filter-ignored"16
if (ignored != selectIgnored) return false17
val name = caseName.toCharArray()18
val filter = arguments[2L].toCharArray()19
var start = 0L20
while (start <= name.size - filter.size) {21
var index = 0L22
while (index < filter.size && name[start + index] == filter[index]) index += 1L23
if (index == filter.size) return true24
start += 1L25
}26
return false27
}28
if (arguments[1L] == "--scoop-test-child") {29
return arguments.size == 3L && arguments[2L] == caseIndex30
}31
val marker = if (arguments[1L] == "--scoop-test-isolate-all") 2L else 1L32
if (arguments.size <= marker || arguments[marker] != "--scoop-test-cases") return false33
var index = marker + 1L34
while (index < arguments.size) {35
if (arguments[index] == caseIndex) { return true }36
index += 1L37
}38
return false39
}