mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-25 01:49:06 -05:00
test: deflake headless system-test on webkit (appData ensureDir/symlink race) (#33812)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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'] = `
|
||||
|
||||
====================================================================================================
|
||||
|
||||
@@ -51,7 +51,6 @@ describe('e2e headless', function () {
|
||||
},
|
||||
},
|
||||
headed: false,
|
||||
snapshot: true,
|
||||
})
|
||||
|
||||
// NOTE: cypress run --headed
|
||||
|
||||
Reference in New Issue
Block a user