@@ -2,7 +2,8 @@ import * as vscode from 'vscode';
22import { TextDecoder } from 'util' ;
33import { parseTestsFile } from './parser' ;
44import { join } from 'path' ;
5- import { execShellCommand , getCwdUri , getExecutableFilename , writeLocalFile } from './driverUtils' ;
5+ import { execShellCommand , getCwdUri , getExecutableFilename ,
6+ getTimeoutTime , getValgrindTimeoutTime , writeLocalFile } from './driverUtils' ;
67import { existsSync , unlinkSync } from 'fs' ;
78
89const textDecoder = new TextDecoder ( 'utf-8' ) ;
@@ -119,16 +120,28 @@ export class TestCase {
119120let wsFolderUri = vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath ;
120121let execPath = join ( wsFolderUri , getExecutableFilename ( ) ) ;
121122
122- let result = await execShellCommand ( execPath + ' ' + this . name ) ;
123+ let timeouttime = getTimeoutTime ( ) . toString ( ) ;
124+ let valgrindtimeouttime = getValgrindTimeoutTime ( ) . toString ( ) ;
125+ let result = await execShellCommand ( 'timeout --preserve-status ' + timeouttime + ' ' + execPath + ' ' + this . name ) ;
123126const duration = Date . now ( ) - start ;
124127if ( ! result . passed ) {
125- let message = new vscode . TestMessage ( "stdout: " + result . stdout + "\n stderr: " + result . stderr ) ;
128+ let message = new vscode . TestMessage ( "" ) ;
129+ if ( result . exitcode === 143 ) {
130+ message = new vscode . TestMessage ( "stdout: " + result . stdout + "\n stderr: code timed out (>" + timeouttime + "s to run) while running test" ) ;
131+ } else {
132+ message = new vscode . TestMessage ( "stdout: " + result . stdout + "\n stderr: " + result . stderr ) ;
133+ }
126134message . location = new vscode . Location ( item . uri ! , item . range ! ) ;
127135options . failed ( item , message , duration ) ;
128136} else {
129- let valgrindResult = await execShellCommand ( 'valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ' + execPath + ' ' + this . name ) ;
130- if ( ! valgrindResult . passed ) {
131- let message = new vscode . TestMessage ( "stdout: " + valgrindResult . stdout + "\n stderr: " + valgrindResult . stderr ) ;
137+ let valgrindResult = await execShellCommand ( 'timeout --preserve-status ' + valgrindtimeouttime + ' valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ' + execPath + ' ' + this . name ) ;
138+ if ( ! valgrindResult . passed ) {
139+ let message = new vscode . TestMessage ( "" ) ;
140+ if ( valgrindResult . exitcode === 143 ) {
141+ message = new vscode . TestMessage ( "stdout: " + valgrindResult . stdout + "\n stderr: valgrind timed out (>" + valgrindtimeouttime + "s to run while running test" ) ;
142+ } else {
143+ message = new vscode . TestMessage ( "stdout: " + valgrindResult . stdout + "\n stderr: " + valgrindResult . stderr ) ;
144+ }
132145message . location = new vscode . Location ( item . uri ! , item . range ! ) ;
133146options . failed ( item , message , duration ) ;
134147} else {