ML - Fixed a failing test (#13080)

* Fixed a failing test
This commit is contained in:
Leila Lali
2020-10-27 06:42:33 -07:00
committed by GitHub
parent eec6f64d62
commit f97ae9e570
2 changed files with 20 additions and 11 deletions

View File

@@ -27,15 +27,23 @@ function createContext(): TestContext {
};
}
function execFolderListCommand(context: TestContext, service : ProcessService): Promise<string> {
function execFolderListCommand(context: TestContext, service: ProcessService): Promise<string> {
if (utils.isWindows()) {
return service.execScripts('cmd', ['dir', '.'], [], context.outputChannel);
} else {
return service.execScripts('/bin/sh', ['-c', 'ls'], [], context.outputChannel);
return service.execScripts('/bin/sh', ['ls'], [], context.outputChannel);
}
}
function execFolderListBufferedCommand(context: TestContext, service : ProcessService): Promise<string> {
function execGetCharacterCommand(context: TestContext, service: ProcessService): Promise<string> {
if (utils.isWindows()) {
return service.execScripts('cmd', ['set', '/p', 'asd="Hit enter"'], [], context.outputChannel);
} else {
return service.execScripts('/bin/sh', ['read'], [], context.outputChannel);
}
}
function execFolderListBufferedCommand(context: TestContext, service: ProcessService): Promise<string> {
if (utils.isWindows()) {
return service.executeBufferedCommand('dir', context.outputChannel);
} else {
@@ -44,20 +52,20 @@ function execFolderListBufferedCommand(context: TestContext, service : ProcessSe
}
describe('Process Service', () => {
it('Executing a valid script should return successfully', async function (): Promise<void> {
it('execScripts should return successfully', async function (): Promise<void> {
const context = createContext();
let service = new ProcessService();
await should(execFolderListCommand(context, service)).resolved();
});
it('execFolderListCommand should reject if command time out @UNSTABLE@', async function (): Promise<void> {
it('execScripts should reject if command times out', async function (): Promise<void> {
const context = createContext();
let service = new ProcessService();
service.timeout = 10;
await should(execFolderListCommand(context, service)).rejected();
await should(execGetCharacterCommand(context, service)).rejected();
});
it('executeBufferedCommand should resolve give valid script', async function (): Promise<void> {
it('execScripts should resolve give valid script', async function (): Promise<void> {
const context = createContext();
let service = new ProcessService();
service.timeout = 2000;