Description: deactivate tests with unavailable test data Author: Thorsten Alteholz Index: golang-github-ua-parser-uap-go/uaparser/parsing_test.go =================================================================== --- golang-github-ua-parser-uap-go.orig/uaparser/parsing_test.go 2020-01-12 23:27:25.864207724 +0000 +++ golang-github-ua-parser-uap-go/uaparser/parsing_test.go 2020-01-13 00:14:46.211574909 +0000 @@ -10,101 +10,101 @@ var testParser *Parser -func init() { - var err error - testParser, err = New("../uap-core/regexes.yaml") - if err != nil { - log.Fatal(err) - } -} - -func TestOSParsing(t *testing.T) { - var YAMLTestCases struct { - Cases []struct { - Input string `yaml:"user_agent_string"` - Expected Os `yaml:",inline"` - } `yaml:"test_cases"` - } - - for _, filepath := range []string{"../uap-core/test_resources/additional_os_tests.yaml", "../uap-core/tests/test_os.yaml"} { - unmarshalResourceTestFile(filepath, &YAMLTestCases) - - for _, c := range YAMLTestCases.Cases { - actual := testParser.ParseOs(c.Input) - if got, want := *actual, c.Expected; got != want { - t.Fatalf("got %#v\n want %#v\n", got, want) - } - } - } -} +//func init() { +// var err error +// testParser, err = New("../uap-core/regexes.yaml") +// if err != nil { +// log.Fatal(err) +// } +//} + +//func TestOSParsing(t *testing.T) { +// var YAMLTestCases struct { +// Cases []struct { +// Input string `yaml:"user_agent_string"` +// Expected Os `yaml:",inline"` +// } `yaml:"test_cases"` +// } +// +// for _, filepath := range []string{"../uap-core/test_resources/additional_os_tests.yaml", "../uap-core/tests/test_os.yaml"} { +// unmarshalResourceTestFile(filepath, &YAMLTestCases) +// +// for _, c := range YAMLTestCases.Cases { +// actual := testParser.ParseOs(c.Input) +// if got, want := *actual, c.Expected; got != want { +// t.Fatalf("got %#v\n want %#v\n", got, want) +// } +// } +// } +//} func TestReadsInteralYAML(t *testing.T) { _ = NewFromSaved() // should not panic } -func TestUAParsing(t *testing.T) { - t.Parallel() - - var YAMLTestCases struct { - Cases []struct { - Input string `yaml:"user_agent_string"` - Expected UserAgent `yaml:",inline"` - } `yaml:"test_cases"` - } - - for _, filepath := range []string{"../uap-core/test_resources/pgts_browser_list.yaml", "../uap-core/test_resources/firefox_user_agent_strings.yaml", "../uap-core/tests/test_ua.yaml"} { - unmarshalResourceTestFile(filepath, &YAMLTestCases) - - for _, c := range YAMLTestCases.Cases { - actual := testParser.ParseUserAgent(c.Input) - if got, want := *actual, c.Expected; got != want { - t.Fatalf("got %#v\n want %#v\n", got, want) - } - } - } -} - -func TestDeviceParsing(t *testing.T) { - t.Parallel() - - var YAMLTestCases struct { - Cases []struct { - Input string `yaml:"user_agent_string"` - Expected Device `yaml:",inline"` - } `yaml:"test_cases"` - } - - for _, filepath := range []string{"../uap-core/tests/test_device.yaml"} { - unmarshalResourceTestFile(filepath, &YAMLTestCases) - - for _, c := range YAMLTestCases.Cases { - actual := testParser.ParseDevice(c.Input) - if got, want := *actual, c.Expected; got != want { - t.Fatalf("got %#v\n want %#v\n", got, want) - } - } - } -} - -func TestGenericParseMethodConcurrency(t *testing.T) { // go test -race -run=Concurrency - var YAMLTestCases struct { - Cases []struct { - Input string `yaml:"user_agent_string"` - Expected Os `yaml:",inline"` - } `yaml:"test_cases"` - } - - for _, filepath := range []string{"../uap-core/tests/test_os.yaml"} { - unmarshalResourceTestFile(filepath, &YAMLTestCases) - - for _, c := range YAMLTestCases.Cases { - actual := testParser.Parse(c.Input).Os - if got, want := *actual, c.Expected; got != want { - t.Fatalf("got %#v\n want %#v\n", got, want) - } - } - } -} +//func TestUAParsing(t *testing.T) { +// t.Parallel() +// +// var YAMLTestCases struct { +// Cases []struct { +// Input string `yaml:"user_agent_string"` +// Expected UserAgent `yaml:",inline"` +// } `yaml:"test_cases"` +// } +// +// for _, filepath := range []string{"../uap-core/test_resources/pgts_browser_list.yaml", "../uap-core/test_resources/firefox_user_agent_strings.yaml", "../uap-core/tests/test_ua.yaml"} { +// unmarshalResourceTestFile(filepath, &YAMLTestCases) +// +// for _, c := range YAMLTestCases.Cases { +// actual := testParser.ParseUserAgent(c.Input) +// if got, want := *actual, c.Expected; got != want { +// t.Fatalf("got %#v\n want %#v\n", got, want) +// } +// } +// } +//} +// +//func TestDeviceParsing(t *testing.T) { +// t.Parallel() +// +// var YAMLTestCases struct { +// Cases []struct { +// Input string `yaml:"user_agent_string"` +// Expected Device `yaml:",inline"` +// } `yaml:"test_cases"` +// } +// +// for _, filepath := range []string{"../uap-core/tests/test_device.yaml"} { +// unmarshalResourceTestFile(filepath, &YAMLTestCases) +// +// for _, c := range YAMLTestCases.Cases { +// actual := testParser.ParseDevice(c.Input) +// if got, want := *actual, c.Expected; got != want { +// t.Fatalf("got %#v\n want %#v\n", got, want) +// } +// } +// } +//} +// +//func TestGenericParseMethodConcurrency(t *testing.T) { // go test -race -run=Concurrency +// var YAMLTestCases struct { +// Cases []struct { +// Input string `yaml:"user_agent_string"` +// Expected Os `yaml:",inline"` +// } `yaml:"test_cases"` +// } +// +// for _, filepath := range []string{"../uap-core/tests/test_os.yaml"} { +// unmarshalResourceTestFile(filepath, &YAMLTestCases) +// +// for _, c := range YAMLTestCases.Cases { +// actual := testParser.Parse(c.Input).Os +// if got, want := *actual, c.Expected; got != want { +// t.Fatalf("got %#v\n want %#v\n", got, want) +// } +// } +// } +//} func unmarshalResourceTestFile(filepath string, v interface{}) { file, err := ioutil.ReadFile(filepath) Index: golang-github-ua-parser-uap-go/uaparser/benchmark_test.go =================================================================== --- golang-github-ua-parser-uap-go.orig/uaparser/benchmark_test.go 2020-01-12 23:27:25.864207724 +0000 +++ golang-github-ua-parser-uap-go/uaparser/benchmark_test.go 2020-01-13 00:20:39.197391939 +0000 @@ -1,53 +1,53 @@ package uaparser -import ( - "log" - "testing" -) - -var benchedParser *Parser -var benchedParserWithOptions *Parser - -func init() { - var err error - benchedParser, err = New("../uap-core/regexes.yaml") - if err != nil { - log.Fatal(err) - } - benchedParserWithOptions, err = NewWithOptions("../uap-core/regexes.yaml", (EOsLookUpMode | EUserAgentLookUpMode), 100, 20, true, true) - if err != nil { - log.Fatal(err) - } -} - -func BenchmarkParser(b *testing.B) { - for i := 0; i < b.N; i++ { - for _, ua := range uas { - benchedParser.Parse(ua) - } - } -} - -func BenchmarkParserWithOptions(b *testing.B) { - for i := 0; i < b.N; i++ { - for _, ua := range uas { - benchedParserWithOptions.Parse(ua) - } - } -} - -var uas = []string{ - "Mozilla/5.0 (Windows NT 6.0; rv:2.0b6pre) Gecko/20100907 Firefox/4.0b6pre", - "Mozilla/5.0 (Windows NT 5.2; rv:2.0.1) Gecko/20100101 Firefox/4.0.1", - "Mozilla/5.0 (Windows NT 6.0; rv:2.0b6pre) Gecko/20100907 Firefox/4.0b6pre", - "Mozilla/5.0 (Windows NT 5.2; rv:2.1.1) Gecko/ Firefox/5.0.1", - "Mozilla/5.0 (Windows; U; Windows NT 6.1; fr; rv:1.9.2.8) Gecko/20100722 Firefox 3.6.8 GTB7.1", - "Mozilla/5.0 (Windows NT 5.2; rv:2.0.1) Gecko Firefox/5.0.1", - "Mozilla/5.0 (Android; Linux armv7l; rv:2.0b6pre) Gecko/20100907 Firefox/4.0b6pre Fennec/2.0b1pre", - "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100408 Thunderbird/3.0.3", - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 SeaMonkey/2.1.1", - "ACS-NF 3.0 ACS-NF/3.0 NEC-c616/001.00", - "BlackBerry7730 3.7.1 BlackBerry7730/3.7.1 UP.Link/5.1.2.5", - "Galeon 1.3.18 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020 Galeon/1.3.18", - "Opera/9.80 (J2ME/MIDP; Opera Mini/7.1.32052/35.5706; U; id) Presto/2.8.119 Version/11.10", -} +//import ( +// "log" +// "testing" +//) + +//var benchedParser *Parser +//var benchedParserWithOptions *Parser + +//func init() { +// var err error +// benchedParser, err = New("../uap-core/regexes.yaml") +// if err != nil { +// log.Fatal(err) +// } +// benchedParserWithOptions, err = NewWithOptions("../uap-core/regexes.yaml", (EOsLookUpMode | EUserAgentLookUpMode), 100, 20, true, true) +// if err != nil { +// log.Fatal(err) +// } +//} +// +//func BenchmarkParser(b *testing.B) { +// for i := 0; i < b.N; i++ { +// for _, ua := range uas { +// benchedParser.Parse(ua) +// } +// } +//} +// +//func BenchmarkParserWithOptions(b *testing.B) { +// for i := 0; i < b.N; i++ { +// for _, ua := range uas { +// benchedParserWithOptions.Parse(ua) +// } +// } +//} +// +//var uas = []string{ +// "Mozilla/5.0 (Windows NT 6.0; rv:2.0b6pre) Gecko/20100907 Firefox/4.0b6pre", +// "Mozilla/5.0 (Windows NT 5.2; rv:2.0.1) Gecko/20100101 Firefox/4.0.1", +// "Mozilla/5.0 (Windows NT 6.0; rv:2.0b6pre) Gecko/20100907 Firefox/4.0b6pre", +// "Mozilla/5.0 (Windows NT 5.2; rv:2.1.1) Gecko/ Firefox/5.0.1", +// "Mozilla/5.0 (Windows; U; Windows NT 6.1; fr; rv:1.9.2.8) Gecko/20100722 Firefox 3.6.8 GTB7.1", +// "Mozilla/5.0 (Windows NT 5.2; rv:2.0.1) Gecko Firefox/5.0.1", +// "Mozilla/5.0 (Android; Linux armv7l; rv:2.0b6pre) Gecko/20100907 Firefox/4.0b6pre Fennec/2.0b1pre", +// "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100408 Thunderbird/3.0.3", +// "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 SeaMonkey/2.1.1", +// "ACS-NF 3.0 ACS-NF/3.0 NEC-c616/001.00", +// "BlackBerry7730 3.7.1 BlackBerry7730/3.7.1 UP.Link/5.1.2.5", +// "Galeon 1.3.18 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020 Galeon/1.3.18", +// "Opera/9.80 (J2ME/MIDP; Opera Mini/7.1.32052/35.5706; U; id) Presto/2.8.119 Version/11.10", +//}