Install latexindent in Actions and try a test

This commit is contained in:
James-Yu 2023-01-10 15:46:29 +08:00
parent c63ff139a0
commit 98e4c8e13f
7 changed files with 88 additions and 20 deletions

View File

@ -1,6 +1,6 @@
name: TeX Live on Linux
env:
cache-version: v11
cache-version: v12
on: [push]
permissions:
@ -38,17 +38,23 @@ jobs:
tlmgr update --self
tlmgr install collection-latex
tlmgr install import subfiles latexmk makeindex
tlmgr install chktex lacheck
tlmgr install chktex lacheck latexindent
if: steps.cache-texlive.outputs.cache-hit != 'true'
- name: Download latexindent binary
run: |
curl -s -O -L http://mirrors.ctan.org/support/latexindent/bin/linux/latexindent
mv latexindent /tmp/texlive/bin/x86_64-linux/latexindent-binary
chmod +x /tmp/texlive/bin/x86_64-linux/latexindent-binary
if: steps.cache-texlive.outputs.cache-hit != 'true'
- uses: actions/setup-node@v3
with:
node-version: '16'
- run: latex -v
- run: |
which perl
perl -v
- run: perl -MCwd -e 'print $Cwd::VERSION."\n";'
- run: latexmk -v
perl -MCwd -e 'print $Cwd::VERSION."\n";'
- run: |
latex -v
latexmk -v
- run: |
npm ci
npm run compile

View File

@ -1,6 +1,6 @@
name: TeX Live on macOS
env:
cache-version: v11
cache-version: v12
on: [push]
permissions:
@ -38,17 +38,22 @@ jobs:
run: |
tlmgr install collection-latex
tlmgr install import subfiles latexmk makeindex
tlmgr install chktex lacheck
tlmgr install chktex lacheck latexindent
if: steps.cache-texlive.outputs.cache-hit != 'true'
- name: Download latexindent binary
run: |
curl -s -O -L http://mirrors.ctan.org/support/latexindent/bin/macos/latexindent
[ -d /Users/runner/texlive/bin/x86_64-darwin/ ] && mv latexindent /Users/runner/texlive/bin/x86_64-darwin/latexindent-binary && chmod +x /Users/runner/texlive/bin/x86_64-darwin/latexindent-binary || [ -d /Users/runner/texlive/bin/universal-darwin/ ] && mv latexindent /Users/runner/texlive/bin/universal-darwin/latexindent-binary && chmod +x /Users/runner/texlive/bin/universal-darwin/latexindent-binary
if: steps.cache-texlive.outputs.cache-hit != 'true'
- uses: actions/setup-node@v3
with:
node-version: '16'
- run: latex -v
- run: |
which perl
perl -v
- run: perl -MCwd -e 'print $Cwd::VERSION."\n";'
- run: latexmk -v
perl -MCwd -e 'print $Cwd::VERSION."\n";'
- run: |
latex -v
latexmk -v
- run: |
npm ci
npm run compile

View File

@ -1,6 +1,6 @@
name: TeX Live on Windows
env:
cache-version: v11
cache-version: v12
on: [push]
permissions:
@ -42,15 +42,22 @@ jobs:
run: |
tlmgr install collection-latex
tlmgr install import subfiles latexmk makeindex
tlmgr install chktex lacheck
tlmgr install chktex lacheck latexindent
if: steps.cache-texlive.outputs.cache-hit != 'true'
- name: Download latexindent binary
run: |
curl -s -O -L http://mirrors.ctan.org/support/latexindent/bin/windows/latexindent.exe
move "latexindent.exe" "D:\texlive\bin\win32\latexindent-binary.exe"
if: steps.cache-texlive.outputs.cache-hit != 'true'
- uses: actions/setup-node@v3
with:
node-version: '16'
- run: latex -v
- run: perl -v
- run: perl -MCwd -e 'print $Cwd::VERSION."\n";'
- run: latexmk -v
- run: |
perl -v
perl -MCwd -e 'print $Cwd::VERSION."\n";'
- run: |
latex -v
latexmk -v
- run: |
npm ci
npm run compile

2
.vscode/launch.json vendored
View File

@ -32,7 +32,7 @@
"preLaunchTask": "task-watch-all",
"env": {
"LATEXWORKSHOP_CI": "1",
"LATEXWORKSHOP_SUITE": ""
"LATEXWORKSHOP_SUITE": "09_formatter"
}
},
{

View File

@ -0,0 +1,4 @@
\documentclass{article}
\begin{document}
abc
\end{document}

View File

@ -0,0 +1,46 @@
import * as vscode from 'vscode'
import * as path from 'path'
import * as assert from 'assert'
import rimraf from 'rimraf'
import * as lw from '../../src/lw'
import { sleep, runTest, openActive, loadTestFile } from './utils'
suite('Formatter test suite', () => {
const suiteName = path.basename(__filename).replace('.test.js', '')
let fixture = path.resolve(__dirname, '../../../test/fixtures/testground')
const fixtureName = 'testground'
suiteSetup(() => {
fixture = path.resolve(lw.extensionRoot, 'test/fixtures/testground')
})
setup(async () => {
await vscode.commands.executeCommand('latex-workshop.activate')
await vscode.workspace.getConfiguration('latex-workshop').update('latexindent.path', 'latexindent-binary')
})
teardown(async () => {
await vscode.commands.executeCommand('workbench.action.closeAllEditors')
lw.manager.rootFile = undefined
await vscode.workspace.getConfiguration('latex-workshop').update('latexindent.path', undefined)
await vscode.workspace.getConfiguration('latex-workshop').update('latexindent.args', undefined)
if (path.basename(fixture) === 'testground') {
rimraf(fixture + '/{*,.vscode/*}', (e) => {if (e) {console.error(e)}})
await sleep(500) // Required for pooling
}
})
runTest({suiteName, fixtureName, testName: 'test latex formatter with dummy'}, async () => {
await loadTestFile(fixture, [
{src: 'formatter/latex_base.tex', dst: 'main.tex'}
])
await openActive(fixture, 'main.tex')
const original = vscode.window.activeTextEditor?.document.getText()
await vscode.commands.executeCommand('editor.action.formatDocument')
const formatted = vscode.window.activeTextEditor?.document.getText()
assert.notStrictEqual(original, formatted)
})
})

View File

@ -7,7 +7,7 @@ export function run(): Promise<void> {
const mocha = new Mocha({
ui: 'tdd',
color: true,
timeout: 15000,
timeout: process.env['LATEXWORKSHOP_CLI'] ? 15000 : 10000,
retries: process.env['LATEXWORKSHOP_CLI'] ? 5 : 0
})