diff --git a/packages/server/lib/util/app_data.js b/packages/server/lib/util/app_data.js index 6bb844e00a..3fe2e76572 100644 --- a/packages/server/lib/util/app_data.js +++ b/packages/server/lib/util/app_data.js @@ -114,14 +114,12 @@ module.exports = { }, ensure () { + // ensureSymlinkAsync lstats its src, so the appData dir must exist + // before symlink() runs — these can't be parallelized. const ensure = () => { return this.removeSymlink() - .then(() => { - return Promise.join( - fs.ensureDirAsync(this.path()), - !isProduction() ? this.symlink() : undefined, - ) - }) + .then(() => fs.ensureDirAsync(this.path())) + .then(() => (!isProduction() ? this.symlink() : undefined)) } // try twice to ensure the dir diff --git a/packages/server/test/unit/util/app_data_spec.js b/packages/server/test/unit/util/app_data_spec.js index 6d58044b20..011f39b625 100644 --- a/packages/server/test/unit/util/app_data_spec.js +++ b/packages/server/test/unit/util/app_data_spec.js @@ -2,7 +2,9 @@ require('../../spec_helper') const os = require('os') const osPath = require('ospath') const path = require('path') +const Promise = require('bluebird') +const { fs } = require('../../../lib/util/fs') const AppData = require(`../../../lib/util/app_data`) describe('lib/util/app_data', () => { @@ -31,6 +33,30 @@ describe('lib/util/app_data', () => { }) }) + context('#ensure', () => { + it('does not create the symlink until the appData directory exists', async () => { + let ensureDirCompleted = false + let ensureDirCompletedAtSymlinkCall = null + + sinon.stub(fs, 'removeAsync').resolves() + sinon.stub(fs, 'ensureDirAsync').callsFake(() => { + return Promise.delay(50).then(() => { + ensureDirCompleted = true + }) + }) + + sinon.stub(fs, 'ensureSymlinkAsync').callsFake(() => { + ensureDirCompletedAtSymlinkCall = ensureDirCompleted + + return Promise.resolve() + }) + + await AppData.ensure() + + expect(ensureDirCompletedAtSymlinkCall, 'ensureSymlinkAsync was called before the appData directory existed').to.be.true + }) + }) + context('#findCommonAncestor', () => { it('posix', () => { expect(AppData.findCommonAncestor('/a/b/c/d', '/a/b/c/d/')).to.equal('/a/b/c/d') diff --git a/system-tests/__snapshots__/headless_spec.ts.js b/system-tests/__snapshots__/headless_spec.ts.js index 830e9fb71d..ebd35fad59 100644 --- a/system-tests/__snapshots__/headless_spec.ts.js +++ b/system-tests/__snapshots__/headless_spec.ts.js @@ -1,59 +1,3 @@ -exports['e2e headless / tests in headless mode pass'] = ` - -==================================================================================================== - - (Run Starting) - - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ Cypress: 1.2.3 │ - │ Browser: FooBrowser 88 │ - │ Specs: 1 found (headless.cy.js) │ - │ Searched: cypress/e2e/headless.cy.js │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - - -──────────────────────────────────────────────────────────────────────────────────────────────────── - - Running: headless.cy.js (1 of 1) - - - e2e headless spec - ✓ has the expected values for Cypress.browser - ✓ has expected launch args - - - 2 passing - - - (Results) - - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ Tests: 2 │ - │ Passing: 2 │ - │ Failing: 0 │ - │ Pending: 0 │ - │ Skipped: 0 │ - │ Screenshots: 0 │ - │ Video: false │ - │ Duration: X seconds │ - │ Spec Ran: headless.cy.js │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - - -==================================================================================================== - - (Run Finished) - - - Spec Tests Passing Failing Pending Skipped - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ ✔ headless.cy.js XX:XX 2 2 - - - │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - ✔ All specs passed! XX:XX 2 2 - - - - - -` - exports['e2e headless / tests in headed mode pass in !electron'] = ` ==================================================================================================== diff --git a/system-tests/test/headless_spec.ts b/system-tests/test/headless_spec.ts index ac3ef0c269..de697d90f3 100644 --- a/system-tests/test/headless_spec.ts +++ b/system-tests/test/headless_spec.ts @@ -51,7 +51,6 @@ describe('e2e headless', function () { }, }, headed: false, - snapshot: true, }) // NOTE: cypress run --headed