@@ -46,6 +46,84 @@ suite("LLDBDebugConfigurationProvider Tests", () => {
46
46
} ) ;
47
47
} ) ;
48
48
49
+ test ( "allows specifying a 'pid' in the launch configuration" , async ( ) => {
50
+ const configProvider = new LLDBDebugConfigurationProvider (
51
+ "darwin" ,
52
+ instance ( mockToolchain ) ,
53
+ instance ( mockOutputChannel )
54
+ ) ;
55
+ const launchConfig = await configProvider . resolveDebugConfigurationWithSubstitutedVariables (
56
+ undefined ,
57
+ {
58
+ name : "Test Launch Config" ,
59
+ type : SWIFT_LAUNCH_CONFIG_TYPE ,
60
+ request : "attach" ,
61
+ pid : 41038 ,
62
+ }
63
+ ) ;
64
+ expect ( launchConfig ) . to . containSubset ( { pid : 41038 } ) ;
65
+ } ) ;
66
+
67
+ test ( "converts 'pid' property from a string to a number" , async ( ) => {
68
+ const configProvider = new LLDBDebugConfigurationProvider (
69
+ "darwin" ,
70
+ instance ( mockToolchain ) ,
71
+ instance ( mockOutputChannel )
72
+ ) ;
73
+ const launchConfig = await configProvider . resolveDebugConfigurationWithSubstitutedVariables (
74
+ undefined ,
75
+ {
76
+ name : "Test Launch Config" ,
77
+ type : SWIFT_LAUNCH_CONFIG_TYPE ,
78
+ request : "attach" ,
79
+ pid : "41038" ,
80
+ }
81
+ ) ;
82
+ expect ( launchConfig ) . to . containSubset ( { pid : 41038 } ) ;
83
+ } ) ;
84
+
85
+ test ( "shows an error when the 'pid' property is a string that isn't a number" , async ( ) => {
86
+ // Simulate the user clicking the "Configure" button
87
+ mockWindow . showErrorMessage . resolves ( "Configure" as any ) ;
88
+
89
+ const configProvider = new LLDBDebugConfigurationProvider (
90
+ "darwin" ,
91
+ instance ( mockToolchain ) ,
92
+ instance ( mockOutputChannel )
93
+ ) ;
94
+ const launchConfig = await configProvider . resolveDebugConfigurationWithSubstitutedVariables (
95
+ undefined ,
96
+ {
97
+ name : "Test Launch Config" ,
98
+ type : SWIFT_LAUNCH_CONFIG_TYPE ,
99
+ request : "attach" ,
100
+ pid : "not-a-number" ,
101
+ }
102
+ ) ;
103
+ expect ( launchConfig ) . to . be . null ;
104
+ } ) ;
105
+
106
+ test ( "shows an error when the 'pid' property isn't a number or string" , async ( ) => {
107
+ // Simulate the user clicking the "Configure" button
108
+ mockWindow . showErrorMessage . resolves ( "Configure" as any ) ;
109
+
110
+ const configProvider = new LLDBDebugConfigurationProvider (
111
+ "darwin" ,
112
+ instance ( mockToolchain ) ,
113
+ instance ( mockOutputChannel )
114
+ ) ;
115
+ const launchConfig = await configProvider . resolveDebugConfigurationWithSubstitutedVariables (
116
+ undefined ,
117
+ {
118
+ name : "Test Launch Config" ,
119
+ type : SWIFT_LAUNCH_CONFIG_TYPE ,
120
+ request : "attach" ,
121
+ pid : { } ,
122
+ }
123
+ ) ;
124
+ expect ( launchConfig ) . to . be . null ;
125
+ } ) ;
126
+
49
127
suite ( "CodeLLDB selected in settings" , ( ) => {
50
128
let mockLldbConfiguration : MockedObject < vscode . WorkspaceConfiguration > ;
51
129
const mockLLDB = mockGlobalModule ( lldb ) ;
0 commit comments