3.57. 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 = select_test(T).if_else(
    { CONTROL.try(
        { T.run }
        {(:R) 'OK!' }
        {(:Msg :Traces) 'Failed: {}'.format(Msg) }
      )
    }
    { '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.57.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.57.2. type selector_conf

Conf val for SELECTOR.new.

Selector_conf.exclude(Addr_part)

Excludes tests with the specified addr part.

Selector_conf.exclude(Addr_part)

Includes tests with the specified addr part.