1
1
import node from '../../services/node'
2
2
import { getOutputChannel } from '../../editor/outputChannel'
3
3
import parser from './parser'
4
- // import {setLatestProcess, isLatestProcess } from './throttle'
4
+ import { throttle , debounce } from './throttle'
5
5
6
6
export interface Payload {
7
7
stepId :string
@@ -22,6 +22,11 @@ const createTestRunner = (config: TestRunnerConfig, callbacks: Callbacks) => {
22
22
const outputChannelName = 'TEST_OUTPUT'
23
23
24
24
return async ( payload :Payload , onSuccess ?:( ) => void ) :Promise < void > => {
25
+ const startTime = throttle ( )
26
+ // throttle time early
27
+ if ( ! startTime ) {
28
+ return
29
+ }
25
30
console . log ( '------------------- RUN TEST -------------------' )
26
31
27
32
// flag as running
@@ -33,6 +38,14 @@ const createTestRunner = (config: TestRunnerConfig, callbacks: Callbacks) => {
33
38
} catch ( err ) {
34
39
result = { stdout :err . stdout , stderr :err . stack }
35
40
}
41
+
42
+ // ignore output if not latest process
43
+ // this is a crappy version of debounce
44
+ if ( ! debounce ( startTime ) ) {
45
+ return
46
+ }
47
+ console . log ( '----------------- PROCESS TEST -----------------' )
48
+
36
49
const { stdout, stderr} = result
37
50
38
51
const tap = parser ( stdout || '' )