Skip to content

Commit

Permalink
tests: document edge case and fix the tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Bezzubov <[email protected]>
  • Loading branch information
bzz committed Jan 29, 2019
1 parent 65b9545 commit ef9311e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@ type EnryTestSuite struct {
samplesDir string
}

func TestRegexpEdgeCases(t *testing.T) {
func (s *EnryTestSuite) TestRegexpEdgeCases() {
var regexpEdgeCases = []struct {
lang string
filename string
}{
{lang: "ActionScript", filename: "FooBar.as"},
{lang: "Forth", filename: "asm.fr"},
{lang: "X PixMap", filename: "cc-public_domain_mark_white.pm"},
//{lang: "SQL", filename: "drop_stuff.sql"}, // Classifier strategy fails :/
//{lang: "SQL", filename: "drop_stuff.sql"}, // https://github.com/src-d/enry/issues/194
{lang: "Fstar", filename: "Hacl.Spec.Bignum.Fmul.fst"},
{lang: "C++", filename: "Types.h"},
}

for _, r := range regexpEdgeCases {
filename := fmt.Sprintf(".linguist/samples/%s/%s", r.lang, r.filename)
filename := fmt.Sprintf("%s/samples/%s/%s", s.tmpLinguist, r.lang, r.filename)

content, err := ioutil.ReadFile(filename)
require.NoError(t, err)
require.NoError(s.T(), err)

lang := GetLanguage(r.filename, content)
t.Logf("File:%s, lang:%s", filename, lang)
s.T().Logf("File:%s, lang:%s", filename, lang)

expLang, _ := data.LanguageByAlias(r.lang)
require.EqualValues(t, expLang, lang)
require.EqualValues(s.T(), expLang, lang)
}
}

Expand Down Expand Up @@ -427,7 +427,8 @@ func (s *EnryTestSuite) TestGetLanguageByAlias() {
func (s *EnryTestSuite) TestLinguistCorpus() {
const filenamesDir = "filenames"
var cornerCases = map[string]bool{
"hello.ms": true, //TODO add instead .es
"drop_stuff.sql": true, // https://github.com/src-d/enry/issues/194
// .es and .ice fail heuristics parsing, but do not fail any tests
}

var total, failed, ok, other int
Expand Down

0 comments on commit ef9311e

Please sign in to comment.