mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
handle old versions of latexmk in run count extraction (#30597)
* handle old versions of latexmk in run count extraction the log lines for the run number change from stderr to stdout in TL2022 * extend SimpleLatexFileTest to include TL2017 * reset metrics for each scenario in SimpleLatexFileTests * fix buildscript merge conflict GitOrigin-RevId: fb74f2025d21ddf43be6a3b90ac6f7df4d975db6
This commit is contained in:
@@ -87,7 +87,9 @@ function runLatex(projectId, options, callback) {
|
|||||||
}
|
}
|
||||||
// number of latex runs and whether there were errors
|
// number of latex runs and whether there were errors
|
||||||
const runs =
|
const runs =
|
||||||
output?.stdout?.match(/^Run number \d+ of .*latex/gm)?.length || 0
|
output?.stdout?.match(/^Run number \d+ of .*latex/gm)?.length || // TeXLive 2022 and later
|
||||||
|
output?.stderr?.match(/^Run number \d+ of .*latex/gm)?.length || // TeXLive 2021 and earlier
|
||||||
|
0
|
||||||
const failed = output?.stdout?.match(/^Latexmk: Errors/m) != null ? 1 : 0
|
const failed = output?.stdout?.match(/^Latexmk: Errors/m) != null ? 1 : 0
|
||||||
// counters from latexmk output
|
// counters from latexmk output
|
||||||
stats['latexmk-errors'] = failed
|
stats['latexmk-errors'] = failed
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
clsi
|
clsi
|
||||||
--data-dirs=cache,compiles,output
|
--data-dirs=cache,compiles,output
|
||||||
--dependencies=
|
--dependencies=
|
||||||
--env-add=DOWNLOAD_HOST=http://clsi-nginx:8080,ALLOWED_COMPILE_GROUPS="clsi-perf simple-latex-file",ENABLE_PDF_CACHING="true",PDF_CACHING_ENABLE_WORKER_POOL="true",ALLOWED_IMAGES=quay.io/sharelatex/texlive-full:2025.1,TEXLIVE_IMAGE=quay.io/sharelatex/texlive-full:2025.1,TEX_LIVE_IMAGE_NAME_OVERRIDE=us-east1-docker.pkg.dev/overleaf-ops/ol-docker,TEXLIVE_IMAGE_USER="tex",SANDBOXED_COMPILES="true",SANDBOXED_COMPILES_HOST_DIR_COMPILES=$PWD/compiles,SANDBOXED_COMPILES_HOST_DIR_OUTPUT=$PWD/output
|
--env-add=DOWNLOAD_HOST=http://clsi-nginx:8080,ALLOWED_COMPILE_GROUPS="clsi-perf simple-latex-file",ENABLE_PDF_CACHING="true",PDF_CACHING_ENABLE_WORKER_POOL="true",ALLOWED_IMAGES="quay.io/sharelatex/texlive-full:2017.1 quay.io/sharelatex/texlive-full:2025.1",TEXLIVE_IMAGE=quay.io/sharelatex/texlive-full:2025.1,TEX_LIVE_IMAGE_NAME_OVERRIDE=us-east1-docker.pkg.dev/overleaf-ops/ol-docker,TEXLIVE_IMAGE_USER="tex",SANDBOXED_COMPILES="true",SANDBOXED_COMPILES_HOST_DIR_COMPILES=$PWD/compiles,SANDBOXED_COMPILES_HOST_DIR_OUTPUT=$PWD/output
|
||||||
--env-pass-through=
|
--env-pass-through=
|
||||||
--esmock-loader=False
|
--esmock-loader=False
|
||||||
--node-version=24.13.0
|
--node-version=24.13.0
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ services:
|
|||||||
ALLOWED_COMPILE_GROUPS: "clsi-perf simple-latex-file"
|
ALLOWED_COMPILE_GROUPS: "clsi-perf simple-latex-file"
|
||||||
ENABLE_PDF_CACHING: "true"
|
ENABLE_PDF_CACHING: "true"
|
||||||
PDF_CACHING_ENABLE_WORKER_POOL: "true"
|
PDF_CACHING_ENABLE_WORKER_POOL: "true"
|
||||||
ALLOWED_IMAGES: quay.io/sharelatex/texlive-full:2025.1
|
ALLOWED_IMAGES: "quay.io/sharelatex/texlive-full:2017.1 quay.io/sharelatex/texlive-full:2025.1"
|
||||||
TEXLIVE_IMAGE: quay.io/sharelatex/texlive-full:2025.1
|
TEXLIVE_IMAGE: quay.io/sharelatex/texlive-full:2025.1
|
||||||
TEX_LIVE_IMAGE_NAME_OVERRIDE: us-east1-docker.pkg.dev/overleaf-ops/ol-docker
|
TEX_LIVE_IMAGE_NAME_OVERRIDE: us-east1-docker.pkg.dev/overleaf-ops/ol-docker
|
||||||
TEXLIVE_IMAGE_USER: "tex"
|
TEXLIVE_IMAGE_USER: "tex"
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ services:
|
|||||||
ALLOWED_COMPILE_GROUPS: "clsi-perf simple-latex-file"
|
ALLOWED_COMPILE_GROUPS: "clsi-perf simple-latex-file"
|
||||||
ENABLE_PDF_CACHING: "true"
|
ENABLE_PDF_CACHING: "true"
|
||||||
PDF_CACHING_ENABLE_WORKER_POOL: "true"
|
PDF_CACHING_ENABLE_WORKER_POOL: "true"
|
||||||
ALLOWED_IMAGES: quay.io/sharelatex/texlive-full:2025.1
|
ALLOWED_IMAGES: "quay.io/sharelatex/texlive-full:2017.1 quay.io/sharelatex/texlive-full:2025.1"
|
||||||
TEXLIVE_IMAGE: quay.io/sharelatex/texlive-full:2025.1
|
TEXLIVE_IMAGE: quay.io/sharelatex/texlive-full:2025.1
|
||||||
TEX_LIVE_IMAGE_NAME_OVERRIDE: us-east1-docker.pkg.dev/overleaf-ops/ol-docker
|
TEX_LIVE_IMAGE_NAME_OVERRIDE: us-east1-docker.pkg.dev/overleaf-ops/ol-docker
|
||||||
TEXLIVE_IMAGE_USER: "tex"
|
TEXLIVE_IMAGE_USER: "tex"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { fetchNothing, fetchString } from '@overleaf/fetch-utils'
|
|||||||
import ClsiApp from './helpers/ClsiApp.js'
|
import ClsiApp from './helpers/ClsiApp.js'
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import Settings from '@overleaf/settings'
|
import Settings from '@overleaf/settings'
|
||||||
|
import Metrics from '@overleaf/metrics'
|
||||||
|
|
||||||
describe('Simple LaTeX file', function () {
|
describe('Simple LaTeX file', function () {
|
||||||
const content = `\
|
const content = `\
|
||||||
@@ -21,6 +22,18 @@ Hello world
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: 'simple file (TL2017)',
|
||||||
|
request: {
|
||||||
|
resources: [{ path: 'main.tex', content }],
|
||||||
|
options: {
|
||||||
|
compileGroup: 'simple-latex-file',
|
||||||
|
imageName: 'quay.io/sharelatex/texlive-full:2017.1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// In TL2017 latexmk performs an extra LaTeX pass even for this simple document.
|
||||||
|
expectedRuns: 2,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: 'clsi-perf request',
|
description: 'clsi-perf request',
|
||||||
request: {
|
request: {
|
||||||
@@ -49,6 +62,13 @@ Hello world
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
after(function () {
|
||||||
|
// Clear all metrics after each scenario
|
||||||
|
if (Metrics.prom && Metrics.prom.register) {
|
||||||
|
Metrics.prom.register.resetMetrics()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
it('should return the PDF', function () {
|
it('should return the PDF', function () {
|
||||||
const pdf = Client.getOutputFile(this.body, 'pdf')
|
const pdf = Client.getOutputFile(this.body, 'pdf')
|
||||||
pdf.type.should.equal('pdf')
|
pdf.type.should.equal('pdf')
|
||||||
@@ -111,14 +131,15 @@ Hello world
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const expectedRuns = scenario.expectedRuns ?? 1
|
||||||
// Note: chai's all.keys assertion rejects extra keys
|
// Note: chai's all.keys assertion rejects extra keys
|
||||||
stats.should.have.all.keys(
|
stats.should.have.all.keys(
|
||||||
'isInitialCompile',
|
'isInitialCompile',
|
||||||
'latexmk-errors',
|
'latexmk-errors',
|
||||||
'latex-runs',
|
'latex-runs',
|
||||||
'latex-runs-with-errors',
|
'latex-runs-with-errors',
|
||||||
'latex-runs-1',
|
`latex-runs-${expectedRuns}`,
|
||||||
'latex-runs-with-errors-1',
|
`latex-runs-with-errors-${expectedRuns}`,
|
||||||
'pdf-size',
|
'pdf-size',
|
||||||
...pdfCachingStats
|
...pdfCachingStats
|
||||||
)
|
)
|
||||||
@@ -130,6 +151,11 @@ Hello world
|
|||||||
...pdfCachingTimings
|
...pdfCachingTimings
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should report the correct number of runs', function () {
|
||||||
|
const { stats } = this.body.compile
|
||||||
|
expect(stats['latex-runs']).to.equal(scenario.expectedRuns ?? 1)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user