aboutsummaryrefslogtreecommitdiff
path: root/testcase.go
blob: 4273c882ee4a7128544ac0239ec8a5d179db6ff8 (plain)
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
package planr

import (
  "log"
)

type TestStatus uint

const (
  NOT_RUN TestStatus = iota
  PASSING  
  COMPILATION_FAILURE
  RUNTIME_FAILURE
)

type TestResult struct {
  Id          string
  Status      TestStatus
  DebugOutput string
  TestOutput  string
  Tc          TestCase
}

// Program-wide testcase config
type TestCaseConfig struct {
  Defaults
  Title       string
}

func (c TestCaseConfig) ensureSatisfied(name string) {
  if (c.Adapter == "") {
    log.Fatalf("Adapter must be provided for testcase %s", name)
  }
}

type TestCase struct {
  // absolute path to the test case configuration
  Path   string
  // The canonical name is a semantically meaningful name 
  // guaranteed to be unique among the tests
  // Obtained by replacing separators in the relative path of the 
  // configuration with dots. The `toml` extension is also stripped.
  // rubric/alpha/beta/tc1.toml -> alpha.beta.tc1
  Cname  string
  
  Config TestCaseConfig
  
  // Reorder according to original read order after concurrent operation
  readIdx     int
}

func (tc TestCase) AdapterConfig() InheritableConfig {
  return tc.Config.adapters_[tc.Config.Adapter]
}

type ByReadIdx []TestResult

func (a ByReadIdx) Len() int           { return len(a) }
func (a ByReadIdx) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByReadIdx) Less(i, j int) bool { return a[i].Tc.readIdx < a[j].Tc.readIdx }