Skip to content

Commit

Permalink
debug lines for failing windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Jul 19, 2021
1 parent 83a403c commit f94a533
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
2 changes: 0 additions & 2 deletions lib/internal/fs/copy/copy-sync.js
Expand Up @@ -33,12 +33,10 @@ const {
const fs = require('fs');
const {
chmodSync,
closeSync,
copyFileSync,
existsSync,
lstatSync,
mkdirSync,
openSync,
readdirSync,
readlinkSync,
statSync,
Expand Down
9 changes: 8 additions & 1 deletion lib/internal/fs/copy/copy.js
Expand Up @@ -46,7 +46,6 @@ const {
copyFile,
lstat,
mkdir,
open,
readdir,
readlink,
stat,
Expand All @@ -62,6 +61,7 @@ const {
resolve,
sep,
} = require('path');
const console = require('console');

async function copyFn(src, dest, opts) {
// Warn about using preserveTimestamps on 32-bit node
Expand Down Expand Up @@ -337,7 +337,9 @@ async function copyDir(src, dest, opts) {
async function onLink(destStat, src, dest) {
let resolvedSrc = await readlink(src);
if (!isAbsolute(resolvedSrc)) {
console.info(`resolve src ${dirname(src)} to ${resolvedSrc}`);
resolvedSrc = resolve(dirname(src), resolvedSrc);
console.info(`resolved src ${resolvedSrc}`);
}
if (!destStat) {
return symlink(resolvedSrc, dest);
Expand All @@ -355,7 +357,9 @@ async function onLink(destStat, src, dest) {
throw err;
}
if (!isAbsolute(resolvedDest)) {
console.info(`resolve dest ${dirname(dest)} to ${resolvedDest}`);
resolvedDest = resolve(dirname(dest), resolvedDest);
console.info(`resolved dest ${resolvedDest}`);
}
if (isSrcSubdir(resolvedSrc, resolvedDest)) {
throw new ERR_FS_COPY_TO_SUBDIRECTORY({
Expand All @@ -371,6 +375,9 @@ async function onLink(destStat, src, dest) {
// dest in this case would result in removing src contents
// and therefore a broken symlink would be created.
const srcStat = await stat(src);
console.info(`${src} is directory? ${srcStat.isDirectory()}`);
console.info(`dest/src ${resolvedDest} ${resolvedSrc}`);
console.info(`${isSrcSubdir(resolvedDest, resolvedSrc)}`);
if (srcStat.isDirectory() && isSrcSubdir(resolvedDest, resolvedSrc)) {
throw new ERR_FS_COPY_SYMLINK_TO_SUBDIRECTORY({
code: 'EINVAL',
Expand Down
26 changes: 14 additions & 12 deletions test/parallel/test-fs-copy.js
Expand Up @@ -30,6 +30,19 @@ function nextdir() {

// Callback implementation of copy.


// It returns error if symlink in dest points to location in src.
{
const src = dirname(require.resolve('../fixtures/copy/kitchen-sink'));
const dest = nextdir();
mkdirSync(join(dest, 'a'), { recursive: true });
symlinkSync(src, join(dest, 'a', 'c'));
copy(src, dest, common.mustCall((err) => {
assert.strictEqual(err.code, 'ERR_FS_COPY_SYMLINK_TO_SUBDIRECTORY');
}));
}

/*
// It copies a nested folder structure with files, folders, symlinks.
{
const src = dirname(require.resolve('../fixtures/copy/kitchen-sink'));
Expand Down Expand Up @@ -118,17 +131,6 @@ function nextdir() {
}));
}
// It returns error if symlink in dest points to location in src.
{
const src = dirname(require.resolve('../fixtures/copy/kitchen-sink'));
const dest = nextdir();
mkdirSync(join(dest, 'a'), { recursive: true });
symlinkSync(src, join(dest, 'a', 'c'));
copy(src, dest, common.mustCall((err) => {
assert.strictEqual(err.code, 'ERR_FS_COPY_SYMLINK_TO_SUBDIRECTORY');
}));
}

// It returns error if parent directory of symlink in dest points to src.
{
const src = nextdir();
Expand Down Expand Up @@ -285,7 +287,7 @@ if (!isWindows) {
assertDirEquivalent(src, dest);
}
testCase();
}
}*/

function assertDirEquivalent(dir1, dir2) {
const dir1Entries = [];
Expand Down

0 comments on commit f94a533

Please sign in to comment.