mirror of
https://github.com/rwinkhart/go-highlite.git
synced 2026-08-28 04:46:30 -04:00
Fix tests
This commit is contained in:
+7
-8
@@ -5,24 +5,23 @@ import (
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
"github.com/jessp01/gohighlight"
|
||||
)
|
||||
|
||||
|
||||
func getDefs(t *testing.T, filename string, data []byte, highlight_lexer string) *highlight.Def {
|
||||
var def *highlight.Def
|
||||
func getDefs(t *testing.T, filename string, data []byte, highlight_lexer string) *Def {
|
||||
var def *Def
|
||||
syn_dir := "./syntax_files"
|
||||
|
||||
var defs []*highlight.Def
|
||||
lerr := highlight.ParseSyntaxFiles(syn_dir, &defs)
|
||||
var defs []*Def
|
||||
lerr := ParseSyntaxFiles(syn_dir, &defs)
|
||||
if lerr != nil {
|
||||
t.Errorf("Couldn't get defs from '%s', error: %v\n", syn_dir, lerr)
|
||||
}
|
||||
highlight.ResolveIncludes(defs)
|
||||
ResolveIncludes(defs)
|
||||
|
||||
// Always try to auto detect the best lexer:was
|
||||
if def == nil {
|
||||
def = highlight.DetectFiletype(defs, filename, bytes.Split(data, []byte("\n"))[0])
|
||||
def = DetectFiletype(defs, filename, bytes.Split(data, []byte("\n"))[0])
|
||||
}
|
||||
|
||||
// if a specific lexer was requested by setting the ENV var, try to load it
|
||||
@@ -30,7 +29,7 @@ func getDefs(t *testing.T, filename string, data []byte, highlight_lexer string)
|
||||
syntaxFile, lerr := ioutil.ReadFile(syn_dir + "/" + highlight_lexer + ".yaml")
|
||||
if lerr == nil {
|
||||
// Parse it into a `*highlight.Def`
|
||||
def, _ = highlight.ParseDef(syntaxFile)
|
||||
def, _ = ParseDef(syntaxFile)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user