Skip to content

Commit

Permalink
Testing atime does not really work, just mtime
Browse files Browse the repository at this point in the history
  • Loading branch information
JrMasterModelBuilder committed Oct 10, 2023
1 parent 2e5c114 commit 4e95ce4
Showing 1 changed file with 0 additions and 50 deletions.
50 changes: 0 additions & 50 deletions src/bundle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ import {cleanBundlesDir} from './bundle.spec';

const getDir = async (d: string) => cleanBundlesDir('dummy', d);

// Test atime can be tricky because it can change easily.
// Make testing it optional.
const testAtime = /(1|true|yes)/i.test(
// eslint-disable-next-line no-process-env
process.env.DIR_PROJECTOR_TEST_ATIME || ''
);

const supportsExecutable = !process.platform.startsWith('win');
const supportsSymlinks = !process.platform.startsWith('win');
const supportsSymlinkAttrs = process.platform.startsWith('darwin');
Expand Down Expand Up @@ -164,18 +157,12 @@ void describe('bundle', () => {
notEqual(res0.mtime.getFullYear(), 2001);

const res0A = await st('resources0/a.txt');
if (testAtime) {
notEqual(res0A.atime.getFullYear(), 2001);
}
notEqual(res0A.mtime.getFullYear(), 2001);
if (supportsExecutable) {
strictEqual(isUserExec(res0A.mode), false);
}

const res0B = await st('resources0/d/b.txt');
if (testAtime) {
notEqual(res0B.atime.getFullYear(), 2001);
}
notEqual(res0B.mtime.getFullYear(), 2001);
if (supportsExecutable) {
strictEqual(isUserExec(res0B.mode), false);
Expand All @@ -186,37 +173,21 @@ void describe('bundle', () => {
const res0L2 = await st('resources0/l2.txt');

if (supportsSymlinkAttrs) {
if (testAtime) {
notEqual(res0L1.atime.getFullYear(), 2001);
}
notEqual(res0L1.mtime.getFullYear(), 2001);

if (testAtime) {
notEqual(res0L2.atime.getFullYear(), 2001);
}
notEqual(res0L2.mtime.getFullYear(), 2001);
}
}

const res1 = await st('resources1');
if (testAtime) {
strictEqual(res1.atime.getFullYear(), 2001);
}
strictEqual(res1.mtime.getFullYear(), 2001);

const res1A = await st('resources1/a.txt');
if (testAtime) {
strictEqual(res1A.atime.getFullYear(), 2001);
}
strictEqual(res1A.mtime.getFullYear(), 2001);
if (supportsExecutable) {
strictEqual(isUserExec(res1A.mode), false);
}

const res1B = await st('resources1/d/b.txt');
if (testAtime) {
strictEqual(res1B.atime.getFullYear(), 2001);
}
strictEqual(res1B.mtime.getFullYear(), 2001);
if (supportsExecutable) {
strictEqual(isUserExec(res1B.mode), true);
Expand All @@ -227,17 +198,11 @@ void describe('bundle', () => {
const res1L2 = await st('resources1/l2.txt');

if (supportsSymlinkAttrs) {
if (testAtime) {
strictEqual(res1L1.atime.getFullYear(), 2001);
}
strictEqual(res1L1.mtime.getFullYear(), 2001);
if (supportsExecutable) {
strictEqual(isUserExec(res1L1.mode), true);
}

if (testAtime) {
strictEqual(res1L2.atime.getFullYear(), 2001);
}
strictEqual(res1L2.mtime.getFullYear(), 2001);
if (supportsExecutable) {
strictEqual(isUserExec(res1L2.mode), false);
Expand All @@ -246,24 +211,15 @@ void describe('bundle', () => {
}

const res2 = await st('resources2');
if (testAtime) {
notEqual(res2.atime.getFullYear(), 2002);
}
notEqual(res2.mtime.getFullYear(), 2002);

const res2A = await st('resources2/a.txt');
if (testAtime) {
strictEqual(res2A.atime.getFullYear(), 2002);
}
strictEqual(res2A.mtime.getFullYear(), 2002);
if (supportsExecutable) {
strictEqual(isUserExec(res2A.mode), true);
}

const res2B = await st('resources2/d/b.txt');
if (testAtime) {
strictEqual(res2B.atime.getFullYear(), 2002);
}
strictEqual(res2B.mtime.getFullYear(), 2002);
if (supportsExecutable) {
strictEqual(isUserExec(res2B.mode), false);
Expand All @@ -274,17 +230,11 @@ void describe('bundle', () => {
const res1L2 = await st('resources2/l2.txt');

if (supportsSymlinkAttrs) {
if (testAtime) {
strictEqual(res1L1.atime.getFullYear(), 2002);
}
strictEqual(res1L1.mtime.getFullYear(), 2002);
if (supportsExecutable) {
strictEqual(isUserExec(res1L1.mode), true);
}

if (testAtime) {
strictEqual(res1L2.atime.getFullYear(), 2002);
}
strictEqual(res1L2.mtime.getFullYear(), 2002);
if (supportsExecutable) {
strictEqual(isUserExec(res1L2.mode), false);
Expand Down

0 comments on commit 4e95ce4

Please sign in to comment.