aboutsummaryrefslogtreecommitdiff
path: root/cmd/planr/sub/evaluate.go
blob: c2549bee4cb0fc51ed77c5d27de4c839c58a9bbd (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
package sub

import (
  "golang.flu0r1ne.net/planr"
)

func Evaluate(runner planr.Runner, params []string, cfg planr.Config) {
  dieIncompatibleVersion(cfg)

  tcs := runner.CollectCases()
  trs := runner.Evaluate(tcs)

  earned := 0.0
  total  := 0.0
  passed := 0
  for _, tr := range trs {
    cfg := tr.Tc.Config

    if cfg.Points != nil {
      points := float64(*cfg.Points)

      total += points

      if tr.Status == planr.PASSING {
        earned += points
        passed++
      }
    }

    tcPprint(tr)
  }

  printResults(
    passed,
    len(tcs),
    earned,
    total,
  );
}