aboutsummaryrefslogtreecommitdiff
path: root/adapters/gtest_adapter.go
blob: 4cbaa9c00723fe26f49dff01dc8ef166689a80e7 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package adapters

import (
	"fmt"
	"github.com/BurntSushi/toml"
	"golang.flu0r1ne.net/planr"
        "log"
)

/*
  CONFIGURATION
*/

type GtestDefaults struct {
  Name   *string
  Suite  *string
  File   *string
}

func (child *GtestDefaults) Inherit(p interface{}) {
  parent := p.(*GtestDefaults)

  if(child.Name == nil) {
    child.Name = parent.Name 
  }

  if(child.Suite == nil) {
    child.Suite = parent.Suite
  }

  if(child.File == nil) {
    child.File = parent.File
  }
}


type GtestConfig struct {
  GtestDefaults
}

func primitiveDecode(primitive toml.Primitive, config interface{}) {
  if err := toml.PrimitiveDecode(primitive, config); err != nil {
    log.Fatal(err)
  }
}

func ParseConfig(prim toml.Primitive) planr.InheritableConfig {
    config := GtestConfig{}

    primitiveDecode(prim, &config)

    return &config
}

func ParseDefaultConfig(prim toml.Primitive) planr.InheritableConfig {
    config := GtestDefaults{}

    primitiveDecode(prim, &config)

    return &config
}

/*
  BUILD PROCESS
*/

type GtestAdapter struct {}

func (a GtestAdapter) Config() planr.AdapterConfig {
  return planr.AdapterConfig {
    Name: "gtest",
    ParseConfig: ParseConfig,
    ParseDefaultConfig: ParseDefaultConfig,
  }
}

func (a GtestAdapter) InitializeBuild() {
  fmt.Println("Initializing");
}

func (a GtestAdapter) Build(tc planr.TestCase) {
  fmt.Printf("Building %v\n", tc);
}

func (a GtestAdapter) FinalizeBuild() {
  fmt.Println("Finalizing");
}

func (a GtestAdapter) Evaluate(tc planr.TestCase) planr.TestResult {
  fmt.Printf("Evaluating %v\n", tc);

  return planr.TestResult {}
}

func (a GtestAdapter) Cleanup() {
  fmt.Printf("Cleaning\n")
}