mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
@@ -17,10 +17,6 @@ export class ProcessService {
|
|||||||
const scriptExecution = childProcess.spawn(exeFilePath, args);
|
const scriptExecution = childProcess.spawn(exeFilePath, args);
|
||||||
let timer: NodeJS.Timeout;
|
let timer: NodeJS.Timeout;
|
||||||
let output: string = '';
|
let output: string = '';
|
||||||
scripts.forEach(script => {
|
|
||||||
scriptExecution.stdin.write(`${script}\n`);
|
|
||||||
});
|
|
||||||
scriptExecution.stdin.end();
|
|
||||||
|
|
||||||
// Add listeners to print stdout and stderr if an output channel was provided
|
// Add listeners to print stdout and stderr if an output channel was provided
|
||||||
|
|
||||||
@@ -55,6 +51,11 @@ export class ProcessService {
|
|||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
}, this.timeout);
|
}, this.timeout);
|
||||||
|
|
||||||
|
scripts.forEach(script => {
|
||||||
|
scriptExecution.stdin.write(`${script}\n`);
|
||||||
|
});
|
||||||
|
scriptExecution.stdin.end();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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()) {
|
if (utils.isWindows()) {
|
||||||
return service.execScripts('cmd', ['dir', '.'], [], context.outputChannel);
|
return service.execScripts('cmd', ['dir', '.'], [], context.outputChannel);
|
||||||
} else {
|
} 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()) {
|
if (utils.isWindows()) {
|
||||||
return service.executeBufferedCommand('dir', context.outputChannel);
|
return service.executeBufferedCommand('dir', context.outputChannel);
|
||||||
} else {
|
} else {
|
||||||
@@ -44,20 +52,20 @@ function execFolderListBufferedCommand(context: TestContext, service : ProcessSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('Process Service', () => {
|
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();
|
const context = createContext();
|
||||||
let service = new ProcessService();
|
let service = new ProcessService();
|
||||||
await should(execFolderListCommand(context, service)).resolved();
|
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();
|
const context = createContext();
|
||||||
let service = new ProcessService();
|
let service = new ProcessService();
|
||||||
service.timeout = 10;
|
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();
|
const context = createContext();
|
||||||
let service = new ProcessService();
|
let service = new ProcessService();
|
||||||
service.timeout = 2000;
|
service.timeout = 2000;
|
||||||
|
|||||||
Reference in New Issue
Block a user