1
1
mirror of https://github.com/walles/moar.git synced 2024-10-03 23:17:51 +03:00

Make the tests pass

This commit is contained in:
Johan Walles 2024-04-07 08:25:07 +02:00
parent 4357eda016
commit 917f75d591
4 changed files with 6 additions and 18 deletions

View File

@ -194,8 +194,8 @@ func TestCodeHighlighting(t *testing.T) {
}
func TestCodeHighlight_compressed(t *testing.T) {
// Same as TestCodeHighlighting but with "markdown.md.gz"
reader, err := NewReaderFromFilename("../sample-files/markdown.md.gz", *styles.Get("native"), formatters.TTY16m, nil)
// Same as TestCodeHighlighting but with "compressed-markdown.md.gz"
reader, err := NewReaderFromFilename("../sample-files/compressed-markdown.md.gz", *styles.Get("native"), formatters.TTY16m, nil)
assert.NilError(t, err)
assert.NilError(t, reader._wait())

View File

@ -399,6 +399,10 @@ func NewReaderFromFilenameWithoutStyle(filename string, formatter chroma.Formatt
returnMe.name = &filename
returnMe.Unlock()
if lexer == nil {
returnMe.highlightingDone.Store(true)
}
return returnMe, nil
}

View File

@ -144,22 +144,6 @@ func (r *Reader) _wait() error {
func TestGetLines(t *testing.T) {
for _, file := range getTestFiles(t) {
if strings.HasSuffix(file, ".xz") {
_, err := exec.LookPath("xz")
if err != nil {
t.Log("Not testing xz compressed file, xz not found in $PATH: ", file)
continue
}
}
if strings.HasSuffix(file, ".bz2") {
_, err := exec.LookPath("bzip2")
if err != nil {
t.Log("Not testing bzip2 compressed file, bzip2 not found in $PATH: ", file)
continue
}
}
reader, err := NewReaderFromFilename(file, *styles.Get("native"), formatters.TTY16m, nil)
if err != nil {
t.Errorf("Error opening file <%s>: %s", file, err.Error())