@@ -19,15 +19,24 @@ import { expect } from "chai";
1919import {
2020 continueSession ,
2121 waitForDebugAdapterRequest ,
22- waitForDebugAdapterExit ,
2322 waitUntilDebugSessionTerminates ,
2423} from "../utilities/debug" ;
2524import { Version } from "../../src/utilities/version" ;
2625import { activateExtensionForSuite , folderInRootWorkspace } from "./utilities/testutilities" ;
2726import { WorkspaceContext } from "../../src/WorkspaceContext" ;
2827import { join } from "path" ;
29-
30- suite ( "SwiftSnippet Test Suite" , function ( ) {
28+ import { closeAllEditors } from "../utilities/commands" ;
29+
30+ function normalizePath ( ...segments : string [ ] ) : string {
31+ let path = join ( ...segments ) ;
32+ if ( process . platform === "win32" ) {
33+ path = path + ".exe" ;
34+ path = path . replace ( / \/ / g, "\\" ) ;
35+ }
36+ return path . toLocaleLowerCase ( ) ; // Windows may use d:\ or D:\
37+ }
38+
39+ suite . only ( "SwiftSnippet Test Suite" , function ( ) {
3140 this . timeout ( 120000 ) ;
3241
3342 const uri = testAssetUri ( "defaultPackage/Snippets/hello.swift" ) ;
@@ -56,50 +65,37 @@ suite("SwiftSnippet Test Suite", function () {
5665 } ) ;
5766
5867 suiteTeardown ( async ( ) => {
59- await vscode . commands . executeCommand ( "workbench.action. closeAllEditors" ) ;
68+ closeAllEditors ( ) ;
6069 vscode . debug . removeBreakpoints ( breakpoints ) ;
6170 } ) ;
6271
6372 test ( "Run `Swift: Run Swift Snippet` command for snippet file" , async ( ) => {
6473 const sessionPromise = waitUntilDebugSessionTerminates ( "Run hello" ) ;
65- const exitPromise = waitForDebugAdapterExit ( "Run hello" ) ;
66-
67- await vscode . commands . executeCommand ( "swift.runSnippet" ) ;
6874
69- const exitCode = await exitPromise ;
70- expect ( exitCode ) . to . equal ( 0 ) ;
75+ const succeeded = await vscode . commands . executeCommand ( "swift.runSnippet" ) ;
7176
77+ expect ( succeeded ) . to . be . true ;
7278 const session = await sessionPromise ;
73- let path = join ( testAssetPath ( "defaultPackage" ) , ".build" , "debug" , "hello" ) ;
74- if ( process . platform === "win32" ) {
75- path = path + ".exe" ;
76- }
77- expect ( session . configuration . program ?. toLowerCase ( ) ) . to . equal (
78- path . toLocaleLowerCase ( ) // Windows may use d:\ or D:\
79+ expect ( normalizePath ( session . configuration . program ) ) . to . equal (
80+ normalizePath ( testAssetPath ( "defaultPackage" ) , ".build" , "debug" , "hello" )
7981 ) ;
8082 expect ( session . configuration ) . to . have . property ( "noDebug" , true ) ;
8183 } ) ;
8284
8385 test ( "Run `Swift: Debug Swift Snippet` command for snippet file" , async ( ) => {
8486 const bpPromise = waitForDebugAdapterRequest ( "Run hello" , "stackTrace" ) ;
8587 const sessionPromise = waitUntilDebugSessionTerminates ( "Run hello" ) ;
86- const exitPromise = waitForDebugAdapterExit ( "Run hello" ) ;
8788
88- vscode . commands . executeCommand ( "swift.debugSnippet" ) ;
89+ const succeeded = vscode . commands . executeCommand ( "swift.debugSnippet" ) ;
8990
9091 // Once bp is hit, continue
9192 await bpPromise . then ( ( ) => continueSession ( ) ) ;
9293
93- const exitCode = await exitPromise ;
94- expect ( exitCode ) . to . equal ( 0 ) ;
94+ await expect ( succeeded ) . to . eventually . be . true ;
9595
9696 const session = await sessionPromise ;
97- let path = join ( testAssetPath ( "defaultPackage" ) , ".build" , "debug" , "hello" ) ;
98- if ( process . platform === "win32" ) {
99- path = path + ".exe" ;
100- }
101- expect ( session . configuration . program ?. toLowerCase ( ) ) . to . equal (
102- path . toLocaleLowerCase ( ) // Windows may use d:\ or D:\
97+ expect ( normalizePath ( session . configuration . program ) ) . to . equal (
98+ normalizePath ( testAssetPath ( "defaultPackage" ) , ".build" , "debug" , "hello" )
10399 ) ;
104100 expect ( session . configuration ) . to . not . have . property ( "noDebug" ) ;
105101 } ) ;
0 commit comments