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