8
8
} = require ( "./queries" ) ;
9
9
const child_process = require ( "child_process" ) ;
10
10
const { sendLog } = require ( "./debugger" ) ;
11
+ const { createWebview, reloadWebview } = require ( "./webview" ) ;
11
12
12
13
const environment = process . env . STROVE_ENVIRONMENT ;
13
14
@@ -54,7 +55,11 @@ const startAutomaticTest = () => {
54
55
) &&
55
56
! testRunningFlag
56
57
) {
57
- const terminalWriter = await startTestTerminal ( ) ;
58
+ // const terminalWriter = await startTestTerminal();
59
+ let webviewPanel ;
60
+ let html = "<h3>Automatic test results will be visible below:</h3>" ;
61
+
62
+ let refreshWebviewInterval ;
58
63
59
64
testProcess = {
60
65
process : child_process . spawn ( "/bin/bash" ) ,
@@ -67,9 +72,20 @@ const startAutomaticTest = () => {
67
72
// Locking the ability to run the test again before previous instance finishes
68
73
testRunningFlag = true ;
69
74
75
+ webviewPanel = createWebview ( { html } ) ;
76
+
70
77
testProcess . process . stdin . write (
71
78
`cd ${ automaticTest . folderName } && ${ automaticTest . testStartCommand } ; exit\n`
72
79
) ;
80
+
81
+ refreshWebviewInterval = setInterval (
82
+ ( ) =>
83
+ reloadWebview ( {
84
+ panel : webviewPanel ,
85
+ html : `<pre>${ html } </pre>` ,
86
+ } ) ,
87
+ 500
88
+ ) ;
73
89
} ,
74
90
initEvents : ( ) => {
75
91
// Handle Data
@@ -79,9 +95,12 @@ const startAutomaticTest = () => {
79
95
sendLog ( `startAutomaticTest - STDOUT: ${ response } ` ) ;
80
96
81
97
response = response . split ( / [ \r \n \t ] + / g) ;
82
- terminalWriter . fire (
83
- response . length > 1 ? response . join ( "\r\n" ) : response [ 0 ]
84
- ) ;
98
+ response =
99
+ response . length > 1 ? response . join ( "\r\n" ) : response [ 0 ] ;
100
+
101
+ html += response ;
102
+
103
+ // terminalWriter.fire(response);
85
104
} ) ;
86
105
87
106
testProcess . process . stderr . on ( "data" , ( buffer ) => {
@@ -92,21 +111,37 @@ const startAutomaticTest = () => {
92
111
) ;
93
112
94
113
response = response . split ( / [ \r \n \t ] + / g) ;
95
- terminalWriter . fire (
96
- response . length > 1 ? response . join ( "\r\n" ) : response [ 0 ]
97
- ) ;
114
+ response =
115
+ response . length > 1 ? response . join ( "\r\n" ) : response [ 0 ] ;
116
+
117
+ html += response ;
118
+
119
+ // terminalWriter.fire(response);
98
120
} ) ;
99
121
100
122
// Handle Closure
101
123
testProcess . process . on ( "exit" , ( exitCode ) => {
102
124
sendLog ( `startAutomaticTest - exit: ${ exitCode } ` ) ;
125
+ clearInterval ( refreshWebviewInterval ) ;
103
126
104
127
if ( exitCode === 0 ) {
105
128
sendOutput ( "Test Passed." ) ;
106
129
} else {
107
130
sendOutput ( "Test Failed." ) ;
108
131
}
109
132
133
+ if ( process . env . TEST_REPORT_PATH ) {
134
+ reloadWebview ( {
135
+ panel : webviewPanel ,
136
+ path : `/home/strove/project/${ process . env . TEST_REPORT_PATH } ` ,
137
+ } ) ;
138
+ } else {
139
+ reloadWebview ( {
140
+ panel : webviewPanel ,
141
+ html : `<pre>${ html } </pre>` ,
142
+ } ) ;
143
+ }
144
+
110
145
testRunningFlag = false ;
111
146
} ) ;
112
147
} ,
0 commit comments