@@ -12,7 +12,7 @@ import { CancellationToken, CancellationTokenSource } from 'vscode-jsonrpc';
1212import { CancellationError } from '../../client/common/cancellation' ;
1313import { EXTENSION_ROOT_DIR } from '../../client/common/constants' ;
1414import { IFileSystem } from '../../client/common/platform/types' ;
15- import { IProcessServiceFactory } from '../../client/common/process/types' ;
15+ import { IProcessServiceFactory , Output } from '../../client/common/process/types' ;
1616import { createDeferred } from '../../client/common/utils/async' ;
1717import { noop } from '../../client/common/utils/misc' ;
1818import { concatMultilineString } from '../../client/datascience/common' ;
@@ -198,6 +198,43 @@ suite('Jupyter notebook tests', () => {
198198 }
199199 } ) ;
200200
201+ runTest ( 'Remote' , async ( ) => {
202+ const python = await getNotebookCapableInterpreter ( ) ;
203+ const procService = await processFactory . create ( ) ;
204+
205+ if ( procService && python ) {
206+ const connectionFound = createDeferred ( ) ;
207+ const exeResult = procService . execObservable ( python . path , [ '-m' , 'jupyter' , 'notebook' , '--no-browser' ] , { env : process . env , throwOnStdErr : false } ) ;
208+ disposables . push ( exeResult ) ;
209+
210+ exeResult . out . subscribe ( ( output : Output < string > ) => {
211+ const connectionURL = getConnectionInfo ( output . out ) ;
212+ if ( connectionURL ) {
213+ connectionFound . resolve ( connectionURL ) ;
214+ }
215+ } ) ;
216+
217+ const connString = await connectionFound . promise ;
218+ const uri = connString as string ;
219+
220+ // We have a connection string here, so try to connect jupyterExecution to the notebook server
221+ const server = await jupyterExecution . connectToNotebookServer ( uri ! , true ) ;
222+ if ( ! server ) {
223+ assert . fail ( 'Failed to connect to remote server' ) ;
224+ }
225+ }
226+ } ) ;
227+
228+ function getConnectionInfo ( output : string ) : string | undefined {
229+ const UrlPatternRegEx = / ( h t t p s ? : \/ \/ [ ^ \s ] + ) / ;
230+
231+ const urlMatch = UrlPatternRegEx . exec ( output ) ;
232+ if ( urlMatch ) {
233+ return urlMatch [ 0 ] ;
234+ }
235+ return undefined ;
236+ }
237+
201238 runTest ( 'Failure' , async ( ) => {
202239 // Make a dummy class that will fail during launch
203240 class FailedProcess extends JupyterExecution {
@@ -427,7 +464,7 @@ suite('Jupyter notebook tests', () => {
427464 }
428465
429466 // Try with something we can interrupt
430- let interruptResult = await interruptExecute ( server ,
467+ let interruptResult = await interruptExecute ( server ! ,
431468`import signal
432469import _thread
433470import time
@@ -446,14 +483,14 @@ while keep_going:
446483
447484 // Try again with something that doesn't return. However it should finish before
448485 // we get to our own sleep. Note: We need the print so that the test knows something happened.
449- interruptResult = await interruptExecute ( server , `import time${ os . EOL } time.sleep(4)${ os . EOL } print("foo")` , 7000 , 7000 ) ;
486+ interruptResult = await interruptExecute ( server ! , `import time${ os . EOL } time.sleep(4)${ os . EOL } print("foo")` , 7000 , 7000 ) ;
450487
451488 // Try again with something that doesn't return. Make sure it times out
452- interruptResult = await interruptExecute ( server , `import time${ os . EOL } time.sleep(4)${ os . EOL } print("foo")` , 100 , 7000 ) ;
489+ interruptResult = await interruptExecute ( server ! , `import time${ os . EOL } time.sleep(4)${ os . EOL } print("foo")` , 100 , 7000 ) ;
453490 assert . equal ( interruptResult , InterruptResult . TimedOut ) ;
454491
455492 // The tough one, somethign that causes a kernel reset.
456- interruptResult = await interruptExecute ( server ,
493+ interruptResult = await interruptExecute ( server ! ,
457494`import signal
458495import time
459496import os
0 commit comments