Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lettertwo committed Jul 12, 2023
1 parent 7a3f2c6 commit ffcd4ca
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 27 deletions.
9 changes: 5 additions & 4 deletions packages/core/fs/test/OverlayFS.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'));
});

Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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 () => {
Expand Down
78 changes: 55 additions & 23 deletions packages/core/integration-tests/test/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {'));
Expand All @@ -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 {'));
Expand All @@ -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 {'));
Expand All @@ -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 {'));
Expand All @@ -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'));
Expand Down Expand Up @@ -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'));
Expand Down Expand Up @@ -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'));
Expand Down Expand Up @@ -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'));
Expand All @@ -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'));
Expand All @@ -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'));
Expand Down Expand Up @@ -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'));
Expand All @@ -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'));
Expand All @@ -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'));
Expand All @@ -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'));
Expand All @@ -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'));
Expand Down Expand Up @@ -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'));
Expand Down

0 comments on commit ffcd4ca

Please sign in to comment.