-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retry in the find function for fs.realpathSync method for UNC-paths (#…
…777) Sometimes there are spontaneous issues when working with unc-paths, so retries have been added for them.
- Loading branch information
1 parent
f192965
commit ce5aefa
Showing
8 changed files
with
171 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
import assert = require('assert'); | ||
import * as im from '../_build/internal'; | ||
import testutil = require('./testutil'); | ||
|
||
describe('Is UNC-path Tests', function () { | ||
|
||
before(function (done) { | ||
try { | ||
testutil.initialize(); | ||
} catch (err) { | ||
assert.fail('Failed to load task lib: ' + err.message); | ||
} | ||
done(); | ||
}); | ||
|
||
after(function () { | ||
}); | ||
|
||
it('checks if path is unc path', (done: MochaDone) => { | ||
this.timeout(1000); | ||
|
||
const paths = [ | ||
{ inputPath: '\\server\\path\\to\\file', isUNC: false }, | ||
{ inputPath: '\\\\server\\path\\to\\file', isUNC: true }, | ||
{ inputPath: '\\\\\\server\\path\\to\\file', isUNC: false }, | ||
{ inputPath: '!@#$%^&*()_+', isUNC: false }, | ||
{ inputPath: '\\\\\\\\\\\\', isUNC: false }, | ||
{ inputPath: '1q2w3e4r5t6y', isUNC: false }, | ||
{ inputPath: '', isUNC: false } | ||
]; | ||
|
||
for (let path of paths) { | ||
assert.deepEqual(im._isUncPath(path.inputPath), path.isUNC); | ||
} | ||
|
||
done(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
import assert = require('assert'); | ||
import * as tl from '../_build/task'; | ||
import testutil = require('./testutil'); | ||
|
||
describe('Retry Tests', function () { | ||
|
||
before(function (done) { | ||
try { | ||
testutil.initialize(); | ||
} catch (err) { | ||
assert.fail('Failed to load task lib: ' + err.message); | ||
} | ||
done(); | ||
}); | ||
|
||
after(function () { | ||
}); | ||
|
||
it('retries to execute a function', (done: MochaDone) => { | ||
this.timeout(1000); | ||
|
||
const testError = Error('Test Error'); | ||
|
||
function count(num: number) { | ||
return () => num--; | ||
} | ||
|
||
function fail(count: Function) { | ||
if (count()) { | ||
throw testError; | ||
} | ||
|
||
return 'completed'; | ||
} | ||
|
||
function catchError(func: Function, args: any[]) { | ||
try { | ||
func(...args); | ||
} catch (err) { | ||
return err; | ||
} | ||
} | ||
|
||
assert.deepEqual(catchError(tl.retry, [fail, [count(5)], { continueOnError: false, retryCount: 3 }]), testError); | ||
assert.deepEqual(catchError(tl.retry, [fail, [count(5)], { continueOnError: false, retryCount: 4 }]), testError); | ||
assert.deepEqual(tl.retry(fail, [count(5)], { continueOnError: false, retryCount: 5 }), 'completed'); | ||
assert.deepEqual(tl.retry(fail, [count(5)], { continueOnError: false, retryCount: 6 }), 'completed'); | ||
assert.deepEqual(tl.retry(fail, [count(5)], { continueOnError: true, retryCount: 3 }), undefined); | ||
assert.deepEqual(tl.retry(() => 123, [0, 'a', 1, 'b', 2], { continueOnError: false, retryCount: 7 }), 123); | ||
assert.deepEqual(tl.retry((a: string, b: string) => a + b, [''], { continueOnError: false, retryCount: 7 }), 'undefined'); | ||
|
||
done(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters