3.79. kink/test/SELECTOR

Provides test selection facility.

Selection is evaluated for each test by combination of the following two operations.

include(Addr_part) :: sets the test selected if Addr_part is contained in the addr parts of the test.

exclude(Addr_part) :: sets the test unselected if Addr_part is contained in the addr parts of the test.

Calculation is performed so that the last operation wins. Adding to that, tests with @ignore are always unselected.

Example:

:CONTROL.require_from('kink/')
:TEST.require_from('kink/test/')
:SELECTOR.require_from('kink/test/')

:Tests <- TEST.collect_in{
  TEST.group('@os'){
    TEST.test('linux'){}
    TEST.test('win'){}
  }
  TEST.group('@arch'){
    TEST.test('arm'){}
    TEST.ignore_test('x64'){}
  }
  TEST.group('@memory'){
    TEST.test('ecc'){}
    TEST.test('non-ecc'){}
  }
}

:select_test <- SELECTOR.new{(:S)
  S.exclude('@all')
  S.include('@os')
  S.include('@arch')
}
Tests.each{(:T)
  :Result = if(select_test(T)
    { CONTROL.try(
        { T.run }
        {(:R) 'OK!' }
        {(:Exc) 'Failed: {}'.format(Exc.message) }
      )
    }
    { 'Skipped' }
  )
  stdout.print_line('{} [{}]'.format(Result T.addr))
}
# Output:
#   OK! [@all; @os; linux]
#   OK! [@all; @os; win]
#   OK! [@all; @arch; arm]
#   Skipped [@all; @arch; @ignore; x64]
#   Skipped [@all; @memory; ecc]
#   Skipped [@all; @memory; non-ecc]

3.79.1. SELECTOR.new(...[$config = {}])

Makes a predicate fun which decides whether the arg test should be executed.

$config is a fun which takes a selector_conf.

3.79.2. type selector_conf

Conf val for SELECTOR.new.

C.exclude(Part_regex)

Excludes tests with the specified addr part.

C.include(Part_regex)

Includes tests with the specified addr part.