зеркало из https://github.com/mozilla/scribe.git
make evr tests actual go tests
This commit is contained in:
Родитель
b1d0f19fba
Коммит
90fe0e9a6e
|
@ -0,0 +1,92 @@
|
|||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
// Contributor:
|
||||
// - Aaron Meihm ameihm@mozilla.com
|
||||
|
||||
package scribe_test
|
||||
|
||||
import (
|
||||
"github.com/mozilla/scribe"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type evrTestTable struct {
|
||||
verA string
|
||||
op string
|
||||
verB string
|
||||
}
|
||||
|
||||
var evrTests = []evrTestTable{
|
||||
{"2:3.14.5-1+deb7u1", "=", "2:3.14.5-1+deb7u1"},
|
||||
{"0:2.6.6-6+deb7u2", "=", "0:2.6.6-6+deb7u2"},
|
||||
{"0:2.2.22-13+deb7u3", "=", "0:2.2.22-13+deb7u3"},
|
||||
{"0:0.140-5+deb7u1", "=", "0:0.140-5+deb7u1"},
|
||||
{"0:3.2.60-1+deb7u3", "=", "0:3.2.60-1+deb7u3"},
|
||||
{"0:1.5.3-5+deb7u4", "=", "0:1.5.3-5+deb7u4"},
|
||||
{"2:3.14.5-1+deb7u1", "=", "2:3.14.5-1+deb7u1"},
|
||||
{"0:5.5.38-0+wheezy1", "=", "0:5.5.38-0+wheezy1"},
|
||||
{"0:0.2.4.23-1~deb7u1", "=", "0:0.2.4.23-1~deb7u1"},
|
||||
{"0:2.06-1+deb7u1", "=", "0:2.06-1+deb7u1"},
|
||||
{"0:24.7.0esr-1~deb7u1", "=", "0:24.7.0esr-1~deb7u1"},
|
||||
{"0:2.52-3+nmu2", "=", "0:2.52-3+nmu2"},
|
||||
{"0:7u65-2.5.1-2~deb7u1", "=", "0:7u65-2.5.1-2~deb7u1"},
|
||||
{"0:24.7.0-1~deb7u1", "=", "0:24.7.0-1~deb7u1"},
|
||||
{"0:1.0.1e-2+deb7u9", "=", "0:1.0.1e-2+deb7u9"},
|
||||
{"0:6b31-1.13.3-1~deb7u1", "=", "0:6b31-1.13.3-1~deb7u1"},
|
||||
{"2:7.3.547-7", "=", "2:7.3.547-7"},
|
||||
{"1:7.3.547-7", "<", "2:7.3.547-7"},
|
||||
{"2:7.2.547-7", "<", "2:7.3.547-7"},
|
||||
{"2:7.3.540-7", "<", "2:7.3.547-7"},
|
||||
{"2:7.3.547-6", "<", "2:7.3.547-7"},
|
||||
{"1.0.1e-2+deb7u14", "=", "1.0.1e-2+deb7u14"},
|
||||
{"1.0.1d-2+deb7u14", "<", "1.0.1e-2+deb7u14"},
|
||||
{"1.0.1", "<", "1.0.1e"},
|
||||
{"1.0.1", "=", "1.0.1"},
|
||||
{"1.0.1d", "<", "1.0.1e"},
|
||||
{"0:0.2.4.23-1~deb7u1", "=", "0:0.2.4.23-1~deb7u1"},
|
||||
{"0:0.2.4-1~deb7u1", "<", "0:0.2.4.23-1~deb7u1"},
|
||||
{"0:0.2.4.23-0~deb7u1", "<", "0:0.2.4.23-1~deb7u1"},
|
||||
{"2.6.32-504.el6", "<", "0:2.6.32-504.8.1.el6"},
|
||||
{"1.5.9", "<", "1.5.10"},
|
||||
{"1.5.9", "<", "1.5.10z"},
|
||||
{"1.5.9z", "<", "1.5.10"},
|
||||
{"1.5.9b", "<", "1.5.9f"},
|
||||
{"1.5.9g", "=", "1.5.9g"},
|
||||
{"1.5.10", ">", "1.5.9"},
|
||||
{"f", ">", "a"},
|
||||
{"10", ">", "9"},
|
||||
{"123", "=", "123"},
|
||||
{"1241", "<", "14444"},
|
||||
{"12412", ">", "50"},
|
||||
{"51", ">", "50"},
|
||||
}
|
||||
|
||||
func TestEvrops(t *testing.T) {
|
||||
scribe.Bootstrap()
|
||||
scribe.TestHooks(true)
|
||||
|
||||
for _, x := range evrTests {
|
||||
var opmode int
|
||||
|
||||
switch x.op {
|
||||
case "=":
|
||||
opmode = scribe.EvropEquals
|
||||
case "<":
|
||||
opmode = scribe.EvropLessThan
|
||||
case ">":
|
||||
opmode = scribe.EvropGreaterThan
|
||||
default:
|
||||
t.Fatalf("evr test has invalid operation %v", x.op)
|
||||
}
|
||||
t.Logf("%v %v %v", x.verA, x.op, x.verB)
|
||||
result, err := scribe.TestEvrCompare(opmode, x.verA, x.verB)
|
||||
if err != nil {
|
||||
t.Fatalf("scribe.TestEvrCompare: %v", err)
|
||||
}
|
||||
if !result {
|
||||
t.Fatalf("scribe.TestEvrCompare: failed %v %v %v", x.verA, x.op, x.verB)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
// Contributor:
|
||||
// - Aaron Meihm ameihm@mozilla.com
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"github.com/mozilla/scribe"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Fprint(os.Stderr, "specify input test data file as argument\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Println("starting evr comparison tests")
|
||||
|
||||
fd, err := os.Open(os.Args[1])
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
scanner := bufio.NewScanner(fd)
|
||||
for scanner.Scan() {
|
||||
buf := strings.TrimSpace(scanner.Text())
|
||||
if len(buf) == 0 {
|
||||
continue
|
||||
}
|
||||
fmt.Printf("%v\n", buf)
|
||||
|
||||
var opmode int
|
||||
fields := strings.Fields(buf)
|
||||
if len(fields) != 3 {
|
||||
fmt.Fprintf(os.Stderr, "invalid test string '%s'\n", buf)
|
||||
os.Exit(1)
|
||||
}
|
||||
operator := fields[1]
|
||||
switch operator {
|
||||
case "=":
|
||||
opmode = scribe.EvropEquals
|
||||
case "<":
|
||||
opmode = scribe.EvropLessThan
|
||||
case ">":
|
||||
opmode = scribe.EvropGreaterThan
|
||||
default:
|
||||
fmt.Fprintf(os.Stderr, "unknown operation %v\n", operator)
|
||||
os.Exit(1)
|
||||
}
|
||||
result, err := scribe.TestEvrCompare(opmode, fields[0], fields[2])
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "ERROR %v\n", err)
|
||||
os.Exit(2)
|
||||
}
|
||||
if !result {
|
||||
fmt.Println("FAIL")
|
||||
os.Exit(2)
|
||||
}
|
||||
fmt.Println("PASS")
|
||||
}
|
||||
fd.Close()
|
||||
|
||||
fmt.Println("end evr comparison tests")
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
all:
|
||||
|
||||
runtests:
|
||||
ifndef EVRTESTCMD
|
||||
$(error EVRTESTCMD is undefined, tests must be ran from the root of the repository)
|
||||
endif
|
||||
$(EVRTESTCMD) data; \
|
||||
|
||||
clean:
|
|
@ -1,49 +0,0 @@
|
|||
2:3.14.5-1+deb7u1 = 2:3.14.5-1+deb7u1
|
||||
0:2.6.6-6+deb7u2 = 0:2.6.6-6+deb7u2
|
||||
0:2.2.22-13+deb7u3 = 0:2.2.22-13+deb7u3
|
||||
0:0.140-5+deb7u1 = 0:0.140-5+deb7u1
|
||||
0:3.2.60-1+deb7u3 = 0:3.2.60-1+deb7u3
|
||||
0:1.5.3-5+deb7u4 = 0:1.5.3-5+deb7u4
|
||||
2:3.14.5-1+deb7u1 = 2:3.14.5-1+deb7u1
|
||||
0:5.5.38-0+wheezy1 = 0:5.5.38-0+wheezy1
|
||||
0:0.2.4.23-1~deb7u1 = 0:0.2.4.23-1~deb7u1
|
||||
0:2.06-1+deb7u1 = 0:2.06-1+deb7u1
|
||||
0:24.7.0esr-1~deb7u1 = 0:24.7.0esr-1~deb7u1
|
||||
0:2.52-3+nmu2 = 0:2.52-3+nmu2
|
||||
0:7u65-2.5.1-2~deb7u1 = 0:7u65-2.5.1-2~deb7u1
|
||||
0:24.7.0-1~deb7u1 = 0:24.7.0-1~deb7u1
|
||||
0:1.0.1e-2+deb7u9 = 0:1.0.1e-2+deb7u9
|
||||
0:6b31-1.13.3-1~deb7u1 = 0:6b31-1.13.3-1~deb7u1
|
||||
|
||||
2:7.3.547-7 = 2:7.3.547-7
|
||||
1:7.3.547-7 < 2:7.3.547-7
|
||||
2:7.2.547-7 < 2:7.3.547-7
|
||||
2:7.3.540-7 < 2:7.3.547-7
|
||||
2:7.3.547-6 < 2:7.3.547-7
|
||||
|
||||
1.0.1e-2+deb7u14 = 1.0.1e-2+deb7u14
|
||||
1.0.1d-2+deb7u14 < 1.0.1e-2+deb7u14
|
||||
1.0.1 < 1.0.1e
|
||||
1.0.1 = 1.0.1
|
||||
1.0.1d < 1.0.1e
|
||||
|
||||
0:0.2.4.23-1~deb7u1 = 0:0.2.4.23-1~deb7u1
|
||||
0:0.2.4-1~deb7u1 < 0:0.2.4.23-1~deb7u1
|
||||
0:0.2.4.23-0~deb7u1 < 0:0.2.4.23-1~deb7u1
|
||||
|
||||
2.6.32-504.el6 < 0:2.6.32-504.8.1.el6
|
||||
|
||||
1.5.9 < 1.5.10
|
||||
1.5.9 < 1.5.10z
|
||||
1.5.9z < 1.5.10
|
||||
1.5.9b < 1.5.9f
|
||||
1.5.9g = 1.5.9g
|
||||
|
||||
1.5.10 > 1.5.9
|
||||
f > a
|
||||
|
||||
10 > 9
|
||||
123 = 123
|
||||
1241 < 14444
|
||||
12412 > 50
|
||||
51 > 50
|
Загрузка…
Ссылка в новой задаче