Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration of CopyFilesV2 task to Node 10 #13966

Merged
merged 8 commits into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions Tasks/CopyFilesV2/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('CopyFiles L0 Suite', function () {

after(() => { });

it('copy files from srcdir to destdir', (done: MochaDone) => {
it('copy files from srcdir to destdir', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0copyAllFiles.js');
Expand Down Expand Up @@ -50,7 +50,7 @@ describe('CopyFiles L0 Suite', function () {
done();
});

it('copy files from srcdir to destdir with brackets in src path', (done: MochaDone) => {
it('copy files from srcdir to destdir with brackets in src path', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0copyAllFilesWithBracketsInSrcPath.js');
Expand Down Expand Up @@ -90,7 +90,7 @@ describe('CopyFiles L0 Suite', function () {
done();
});

it('copy files and subtract based on exclude pattern', (done: MochaDone) => {
it('copy files and subtract based on exclude pattern', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0copySubtractExclude.js');
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('CopyFiles L0 Suite', function () {
done();
});

it('fails if Contents not set', (done: MochaDone) => {
it('fails if Contents not set', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0failsIfContentsNotSet.js');
Expand All @@ -133,7 +133,7 @@ describe('CopyFiles L0 Suite', function () {
done();
});

it('fails if SourceFolder not set', (done: MochaDone) => {
it('fails if SourceFolder not set', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0failsIfSourceFolderNotSet.js');
Expand All @@ -145,7 +145,7 @@ describe('CopyFiles L0 Suite', function () {
done();
});

it('fails if TargetFolder not set', (done: MochaDone) => {
it('fails if TargetFolder not set', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0failsIfTargetFolderNotSet.js');
Expand All @@ -157,7 +157,7 @@ describe('CopyFiles L0 Suite', function () {
done();
});

it('fails if SourceFolder not found', (done: MochaDone) => {
it('fails if SourceFolder not found', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0failsIfSourceFolderNotFound.js');
Expand All @@ -169,7 +169,7 @@ describe('CopyFiles L0 Suite', function () {
done();
});

it('fails if target file is a directory', (done: MochaDone) => {
it('fails if target file is a directory', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0failsIfTargetFileIsDir.js');
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('CopyFiles L0 Suite', function () {
done();
});

it('overwrites if specified', (done: MochaDone) => {
it('overwrites if specified', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0overwritesIfSpecified.js');
Expand All @@ -231,7 +231,7 @@ describe('CopyFiles L0 Suite', function () {
done();
});

it('preserves timestamp if specified', (done: MochaDone) => {
it('preserves timestamp if specified', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0preservesTimestampIfSpecified.js');
Expand Down Expand Up @@ -259,7 +259,7 @@ describe('CopyFiles L0 Suite', function () {
done();
});

it('cleans if specified', (done: MochaDone) => {
it('cleans if specified', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0cleansIfSpecified.js');
Expand Down Expand Up @@ -290,7 +290,7 @@ describe('CopyFiles L0 Suite', function () {
done();
});

it('cleans if specified and target is file', (done: MochaDone) => {
it('cleans if specified and target is file', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0cleansIfSpecifiedAndTargetIsFile.js');
Expand Down Expand Up @@ -318,7 +318,7 @@ describe('CopyFiles L0 Suite', function () {
done();
});

it('roots patterns', (done: MochaDone) => {
it('roots patterns', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0rootsPatterns.js');
Expand All @@ -341,7 +341,7 @@ describe('CopyFiles L0 Suite', function () {
});

if (process.platform == 'win32') {
it('overwrites readonly', (done: MochaDone) => {
it('overwrites readonly', (done: Mocha.Done) => {
this.timeout(1000);

let testPath = path.join(__dirname, 'L0overwritesReadonly.js');
Expand Down
5 changes: 3 additions & 2 deletions Tasks/CopyFilesV2/Tests/L0cleansIfSpecified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ runner.registerMockExport('stats', (itemPath: string) => {
}
});
let origReaddirSync = fs.readdirSync;
fs.readdirSync = (p: string | Buffer) => {

fs.readdirSync = (p) => {
console.log('HERE path ' + p);
let result: string[];
let result;
anatolybolshakov marked this conversation as resolved.
Show resolved Hide resolved
if (p == path.normalize('/destDir')) {
result = [ 'clean-subDir', 'clean-file.txt' ];
}
Expand Down
5 changes: 3 additions & 2 deletions Tasks/CopyFilesV2/Tests/L0preservesTimestampIfSpecified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs = require('fs');
import mockanswer = require('azure-pipelines-task-lib/mock-answer');
import mockrun = require('azure-pipelines-task-lib/mock-run');
import path = require('path');
const { promisify } = require('util')
anatolybolshakov marked this conversation as resolved.
Show resolved Hide resolved

let taskPath = path.join(__dirname, '..', 'copyfiles.js');
let runner: mockrun.TaskMockRunner = new mockrun.TaskMockRunner(taskPath);
Expand Down Expand Up @@ -46,9 +47,9 @@ runner.registerMockExport('stats', (itemPath: string) => {
}
});

fs.utimes = function (targetPath, atime, mtime, err) {
fs.utimes = promisify(function (targetPath, atime, mtime, err) {
console.log('Calling fs.utimes on', targetPath);
}
});
runner.registerMock('fs', fs);

runner.run();
Loading