Skip to content

Commit

Permalink
test: add tests for compiler.get_file
Browse files Browse the repository at this point in the history
  • Loading branch information
lervag committed Jun 12, 2023
1 parent fdba876 commit 3ddeafc
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/test-getfile/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
MYVIM ?= nvim --clean --headless

INMAKE := 1
export INMAKE

TESTS := $(wildcard test*.vim)
TESTS := $(TESTS:.vim=)

.PHONY: default $(TESTS)

default: $(TESTS)

$(TESTS):
@$(MYVIM) -u $@.vim
46 changes: 46 additions & 0 deletions test/test-getfile/test_auxdir.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
set nocompatible
let &rtp = '../..,' . &rtp
filetype plugin on

nnoremap q :qall!<cr>
function! Test(file, expected) abort
silent edit test_auxdir/test.tex
let l:file = vimtex#paths#shorten_relative(
\ b:vimtex.compiler.get_file(a:file))
call assert_equal(a:expected, l:file)
bwipeout
endfunction

call Test('pdf', 'test.pdf')

let g:vimtex_compiler_latexmk = {'out_dir': 'out'}
call Test('pdf', 'out/test.pdf')
call Test('aux', 'out/test.aux')
call Test('fls', 'out/test.fls')
call Test('log', 'out/test.log')
call Test('blg', 'out/test.blg')

let g:vimtex_compiler_latexmk = {'aux_dir': 'aux'}
call Test('pdf', 'test.pdf')
call Test('fls', 'test.fls')
call Test('aux', 'aux/test.aux')
call Test('log', 'aux/test.log')
call Test('blg', 'aux/test.blg')

let g:vimtex_compiler_latexmk = {
\ 'out_dir': 'out',
\ 'aux_dir': 'aux'
\}
call Test('pdf', 'out/test.pdf')
call Test('fls', 'out/test.fls')
call Test('aux', 'aux/test.aux')
call Test('log', 'aux/test.log')
call Test('blg', 'aux/test.blg')

call vimtex#log#set_silent()
let $VIMTEX_OUTPUT_DIRECTORY = 'out'
call Test('aux', 'out/test.aux')
call Test('log', 'out/test.log')

call vimtex#test#finished()
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
6 changes: 6 additions & 0 deletions test/test-getfile/test_auxdir/test.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\documentclass{minimal}
\begin{document}

Dummy file

\end{document}

0 comments on commit 3ddeafc

Please sign in to comment.