From 101c4ea4dc487637bd87c7508ffbd47ae19336a5 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Fri, 27 Mar 2020 11:10:27 +0100 Subject: [PATCH] [misc] use a directory in /tmp for temporary data --- services/clsi/entrypoint.sh | 4 --- .../acceptance/js/ExampleDocumentTests.js | 29 +++++++++++-------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/services/clsi/entrypoint.sh b/services/clsi/entrypoint.sh index 3e3f838258..2696574873 100755 --- a/services/clsi/entrypoint.sh +++ b/services/clsi/entrypoint.sh @@ -12,10 +12,6 @@ chown node:node /app/cache chown node:node /app/compiles chown node:node /app/db -# acceptance tests -mkdir -p /app/test/acceptance/fixtures/tmp/ -chown -R node:node /app/test/acceptance/fixtures - # make synctex available for remount in compiles cp /app/bin/synctex /app/bin/synctex-mount/synctex diff --git a/services/clsi/test/acceptance/js/ExampleDocumentTests.js b/services/clsi/test/acceptance/js/ExampleDocumentTests.js index 110b5d6f9a..0134c0e106 100644 --- a/services/clsi/test/acceptance/js/ExampleDocumentTests.js +++ b/services/clsi/test/acceptance/js/ExampleDocumentTests.js @@ -19,11 +19,17 @@ const Client = require('./helpers/Client') const request = require('request') require('chai').should() const fs = require('fs') +const fsExtra = require('fs-extra') const ChildProcess = require('child_process') const ClsiApp = require('./helpers/ClsiApp') const logger = require('logger-sharelatex') const Path = require('path') -const fixturePath = path => Path.normalize(__dirname + '/../fixtures/' + path) +const fixturePath = path => { + if (path.slice(0, 3) === 'tmp') { + return '/tmp/clsi_acceptance_tests' + path.slice(3) + } + return Path.normalize(__dirname + '/../fixtures/' + path) +} const process = require('process') console.log( process.pid, @@ -32,13 +38,6 @@ console.log( process.getgroups(), 'PID' ) -try { - console.log('creating tmp directory', fixturePath('tmp')) - fs.mkdirSync(fixturePath('tmp')) -} catch (error) { - const err = error - console.log(err, fixturePath('tmp'), 'unable to create fixture tmp path') -} const MOCHA_LATEX_TIMEOUT = 60 * 1000 @@ -201,10 +200,16 @@ Client.runServer(4242, fixturePath('examples')) describe('Example Documents', function() { before(function(done) { - return ChildProcess.exec('rm test/acceptance/fixtures/tmp/*').on( - 'exit', - () => ClsiApp.ensureRunning(done) - ) + ClsiApp.ensureRunning(done) + }) + before(function(done) { + fsExtra.remove(fixturePath('tmp'), done) + }) + before(function(done) { + fs.mkdir(fixturePath('tmp'), done) + }) + after(function(done) { + fsExtra.remove(fixturePath('tmp'), done) }) return Array.from(fs.readdirSync(fixturePath('examples'))).map(example_dir =>