mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
fix caching of minted output files in TL2025 (#31455)
GitOrigin-RevId: b82df4d9c7898332b310fd956c5f002bf5b20e39
This commit is contained in:
@@ -252,7 +252,7 @@ export default ResourceWriter = {
|
|||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
path.match(/\.(pygtex|pygstyle)$/) ||
|
path.match(/\.(pygtex|pygstyle)$/) ||
|
||||||
path.match(/(^|\/)_minted-[^\/]+\//)
|
path.match(/(^|\/)_minted(-[^\/]+)?\//)
|
||||||
) {
|
) {
|
||||||
// minted files/directory
|
// minted files/directory
|
||||||
shouldDelete = false
|
shouldDelete = false
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"mustNotDeleteRegex": "minted"
|
||||||
|
}
|
||||||
@@ -8,6 +8,9 @@ import { promisify } from 'node:util'
|
|||||||
import ClsiApp from './helpers/ClsiApp.js'
|
import ClsiApp from './helpers/ClsiApp.js'
|
||||||
import Path from 'node:path'
|
import Path from 'node:path'
|
||||||
import process from 'node:process'
|
import process from 'node:process'
|
||||||
|
import ResourceWriter from '../../../app/js/ResourceWriter.js'
|
||||||
|
import { expect } from 'chai'
|
||||||
|
|
||||||
const fixturePath = path => {
|
const fixturePath = path => {
|
||||||
if (path.slice(0, 3) === 'tmp') {
|
if (path.slice(0, 3) === 'tmp') {
|
||||||
return '/tmp/clsi_acceptance_tests' + path.slice(3)
|
return '/tmp/clsi_acceptance_tests' + path.slice(3)
|
||||||
@@ -154,9 +157,26 @@ describe('Example Documents', function () {
|
|||||||
describe(exampleDir, function () {
|
describe(exampleDir, function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
this.project_id = Client.randomId() + '_' + exampleDir
|
this.project_id = Client.randomId() + '_' + exampleDir
|
||||||
|
this.outputFiles = []
|
||||||
|
// Allow each test to provide a configuration file
|
||||||
|
const checksJsonPath = fixturePath(
|
||||||
|
Path.join('examples', exampleDir, 'checks.json')
|
||||||
|
)
|
||||||
|
this.checks = {}
|
||||||
|
const stats = fs.statSync(checksJsonPath, { throwIfNoEntry: false })
|
||||||
|
if (stats && stats.isFile()) {
|
||||||
|
const rawChecks = fs.readFileSync(checksJsonPath, 'utf8')
|
||||||
|
try {
|
||||||
|
this.checks = JSON.parse(rawChecks)
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(
|
||||||
|
`Failed to parse checks.json for example "${exampleDir}" at path "${checksJsonPath}": ${err.message}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should generate the correct pdf', async function () {
|
it('should generate the correct pdf and output files', async function () {
|
||||||
this.timeout(MOCHA_LATEX_TIMEOUT)
|
this.timeout(MOCHA_LATEX_TIMEOUT)
|
||||||
const body = await Client.compileDirectory(
|
const body = await Client.compileDirectory(
|
||||||
this.project_id,
|
this.project_id,
|
||||||
@@ -169,6 +189,27 @@ describe('Example Documents', function () {
|
|||||||
}
|
}
|
||||||
const pdf = Client.getOutputFile(body, 'pdf')
|
const pdf = Client.getOutputFile(body, 'pdf')
|
||||||
await downloadAndComparePdf(this.project_id, exampleDir, pdf.url)
|
await downloadAndComparePdf(this.project_id, exampleDir, pdf.url)
|
||||||
|
|
||||||
|
// pass the output files on to subsequent tests
|
||||||
|
this.outputFiles = body.compile.outputFiles
|
||||||
|
|
||||||
|
if (this.checks.mustNotDeleteRegex) {
|
||||||
|
const mustNotDeleteRegex = new RegExp(
|
||||||
|
this.checks.mustNotDeleteRegex
|
||||||
|
)
|
||||||
|
// On subsequent compiles the isExtraneousFile method is used
|
||||||
|
// to remove unwanted files - this check ensures that we don't
|
||||||
|
// remove any files that should be kept (e.g. cache files)
|
||||||
|
const filesToBeRemoved = this.outputFiles.filter(file =>
|
||||||
|
ResourceWriter.isExtraneousFile(file.path)
|
||||||
|
)
|
||||||
|
for (const file of filesToBeRemoved) {
|
||||||
|
expect(
|
||||||
|
file.path,
|
||||||
|
'should not remove any files that must be cached'
|
||||||
|
).to.not.match(mustNotDeleteRegex)
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should generate the correct pdf on the second run as well', async function () {
|
it('should generate the correct pdf on the second run as well', async function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user