From 926da5b3d5393fdaef1b865507880c2d0ce08d58 Mon Sep 17 00:00:00 2001 From: Eric Eldredge Date: Mon, 10 Jul 2023 16:57:41 -0400 Subject: [PATCH] Fix tests --- packages/core/fs/test/OverlayFS.test.js | 9 ++- packages/core/integration-tests/test/cache.js | 78 +++++++++++++------ 2 files changed, 60 insertions(+), 27 deletions(-) diff --git a/packages/core/fs/test/OverlayFS.test.js b/packages/core/fs/test/OverlayFS.test.js index a1a80408bee5..b854da5c08da 100644 --- a/packages/core/fs/test/OverlayFS.test.js +++ b/packages/core/fs/test/OverlayFS.test.js @@ -6,6 +6,7 @@ import {MemoryFS} from '../src/MemoryFS'; import WorkerFarm from '@parcel/workers'; import assert from 'assert'; +import path from 'path'; describe('OverlayFS', () => { let underlayFS; @@ -55,7 +56,7 @@ describe('OverlayFS', () => { assert.equal(fs.readFileSync('bar', 'utf8'), 'foo'); assert.equal(underlayFS.readFileSync('foo', 'utf8'), 'foo'); - assert.equal(fs.realpathSync('bar'), '/foo'); + assert.equal(fs.realpathSync('bar'), path.resolve('/foo')); assert(!underlayFS.existsSync('bar')); }); @@ -65,7 +66,7 @@ describe('OverlayFS', () => { baz -> foo`; assert(fs.existsSync('foo')); - assert.equal(fs.realpathSync('baz'), '/foo'); + assert.equal(fs.realpathSync('baz'), path.resolve('/foo')); assert(fs._isSymlink('baz')); await fs.rimraf('foo'); @@ -83,7 +84,7 @@ describe('OverlayFS', () => { baz -> foo`; assert(fs.existsSync('baz')); - assert.equal(fs.realpathSync('baz'), '/foo'); + assert.equal(fs.realpathSync('baz'), path.resolve('/foo')); assert(fs._isSymlink('baz')); await fs.unlink('baz'); @@ -93,7 +94,7 @@ describe('OverlayFS', () => { assert(fs.existsSync('foo')); assert(underlayFS.existsSync('foo')); assert(underlayFS.existsSync('baz')); - assert.equal(underlayFS.realpathSync('baz'), '/foo'); + assert.equal(underlayFS.realpathSync('baz'), path.resolve('/foo')); }); it('tracks nested deletes', async () => { diff --git a/packages/core/integration-tests/test/cache.js b/packages/core/integration-tests/test/cache.js index 4c2e3ac0a1e6..626402cbe0e3 100644 --- a/packages/core/integration-tests/test/cache.js +++ b/packages/core/integration-tests/test/cache.js @@ -3439,8 +3439,10 @@ describe('cache', function () { }, async update(b) { let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css') - ?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css') + ?.filePath, + ), 'utf8', ); assert(css.includes('.a {')); @@ -3460,7 +3462,9 @@ describe('cache', function () { ); let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + ), 'utf8', ); assert(css.includes('.a {')); @@ -3482,8 +3486,10 @@ describe('cache', function () { }, async update(b) { let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css') - ?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css') + ?.filePath, + ), 'utf8', ); assert(css.includes('.a {')); @@ -3502,7 +3508,9 @@ describe('cache', function () { ); let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + ), 'utf8', ); assert(!css.includes('.a {')); @@ -3515,8 +3523,10 @@ describe('cache', function () { entries: ['index.js'], async update(b) { let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css') - ?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css') + ?.filePath, + ), 'utf8', ); assert(css.includes('.index')); @@ -3545,7 +3555,9 @@ describe('cache', function () { ); let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + ), 'utf8', ); assert(css.includes('.index')); @@ -3580,8 +3592,10 @@ describe('cache', function () { }, async update(b) { let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css') - ?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css') + ?.filePath, + ), 'utf8', ); assert(css.includes('.index')); @@ -3610,7 +3624,9 @@ describe('cache', function () { ); let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + ), 'utf8', ); assert(css.includes('.index')); @@ -3637,8 +3653,10 @@ describe('cache', function () { }, async update(b) { let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css') - ?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css') + ?.filePath, + ), 'utf8', ); assert(css.includes('.a')); @@ -3663,7 +3681,9 @@ describe('cache', function () { ); let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + ), 'utf8', ); assert(!css.includes('.a')); @@ -3715,7 +3735,9 @@ describe('cache', function () { let b = await runBundle('index.js'); let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + ), 'utf8', ); assert(css.includes('.d')); @@ -3738,8 +3760,10 @@ describe('cache', function () { }, async update(b) { let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css') - ?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css') + ?.filePath, + ), 'utf8', ); assert(css.includes('.included')); @@ -3756,7 +3780,9 @@ describe('cache', function () { ); let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + ), 'utf8', ); assert(!css.includes('.included')); @@ -3782,8 +3808,10 @@ describe('cache', function () { }, async update(b) { let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css') - ?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css') + ?.filePath, + ), 'utf8', ); assert(css.includes('.included')); @@ -3799,7 +3827,9 @@ describe('cache', function () { ); let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + ), 'utf8', ); assert(!css.includes('.included')); @@ -3841,7 +3871,9 @@ describe('cache', function () { let b = await runBundle('index.sass'); let css = await overlayFS.readFile( - b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + nullthrows( + b.bundleGraph.getBundles().find(b => b.type === 'css')?.filePath, + ), 'utf8', ); assert(css.includes('.d'));