Skip to content

Commit

Permalink
Add tests of auto build.
Browse files Browse the repository at this point in the history
  • Loading branch information
tamuratak committed Mar 7, 2020
1 parent 9db628a commit ea57f38
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ test/fixtures/**/*.synctex*
test/fixtures/**/*.aux
test/fixtures/**/*.fdb_latexmk
test/fixtures/**/*.fls
test/fixtures/**/*.bbl
test/fixtures/**/*.blg
39 changes: 39 additions & 0 deletions test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,45 @@ suite('Buid TeX files test suite', () => {
})
})

runTestWithFixture('fixture033', 'fixture033: auto build main.tex when editing s.tex', async () => {
const fixtureDir = getFixtureDir()
const texFileName = 's.tex'
const pdfFileName = 'main.pdf'
const pdfFilePath = path.join(fixtureDir, pdfFileName)
await assertPdfIsGenerated(pdfFilePath, async () => {
const texFilePath = vscode.Uri.file(path.join(fixtureDir, 'sub', texFileName))
const doc = await vscode.workspace.openTextDocument(texFilePath)
const editor = await vscode.window.showTextDocument(doc)
await sleep(5000)
await editor.edit((builder) => {
builder.insert(new vscode.Position(1, 0), ' ')
})
await doc.save()
})
})

runTestWithFixture('fixture034', 'fixture034: auto build main.tex when editing a bib file', async () => {
const fixtureDir = getFixtureDir()
const bibFileName = 'b.bib'
const texFileName = 't.tex'
const pdfFileName = 't.pdf'
const pdfFilePath = path.join(fixtureDir, pdfFileName)
const texFilePath = vscode.Uri.file(path.join(fixtureDir, texFileName))
const doc = await vscode.workspace.openTextDocument(texFilePath)
await vscode.window.showTextDocument(doc)
await sleep(1000)
await assertPdfIsGenerated(pdfFilePath, async () => {
const bibFilePath = vscode.Uri.file(path.join(fixtureDir, bibFileName))
const bibDoc = await vscode.workspace.openTextDocument(bibFilePath)
const editor = await vscode.window.showTextDocument(bibDoc)
await sleep(1000)
await editor.edit((builder) => {
builder.insert(new vscode.Position(1, 0), ' ')
})
await bibDoc.save()
})
})

//
// Multi-file project build tests
//
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/build/fixture033/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"latex-workshop.latex.rootFile.doNotPrompt": true,
"latex-workshop.latex.rootFile.useSubFile": false
}
6 changes: 6 additions & 0 deletions test/fixtures/build/fixture033/main.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\documentclass{article}
\usepackage{subfiles}
\begin{document}
main main main
\subfile{sub/s}
\end{document}
4 changes: 4 additions & 0 deletions test/fixtures/build/fixture033/sub/s.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\documentclass[../main.tex]{subfiles}
\begin{document}
sub sub sub
\end{document}
1 change: 1 addition & 0 deletions test/fixtures/build/fixture034/b.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6 changes: 6 additions & 0 deletions test/fixtures/build/fixture034/t.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\documentclass{article}
\begin{document}
abc
\bibliographystyle{plain}
\bibliography{b}
\end{document}

0 comments on commit ea57f38

Please sign in to comment.