Skip to content

Commit

Permalink
Migration of CopyFilesV2 task to Node 10 (#13966)
Browse files Browse the repository at this point in the history
* Migration to Node10 base part

* Fixed typing errors

* Revert unnecessary changes

* Bump task version

Co-authored-by: Anatoly Bolshakov <[email protected]>
Co-authored-by: Egor Bryzgalov <[email protected]>
  • Loading branch information
3 people authored Dec 7, 2020
1 parent b1671b4 commit e3b749b
Show file tree
Hide file tree
Showing 15 changed files with 400 additions and 3,987 deletions.
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;
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')

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

0 comments on commit e3b749b

Please sign in to comment.