|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
17 | | -import { debugConfigurationFactory } from '../debug-configuration.factory'; |
| 17 | +import { gdbTargetConfiguration, targetConfigurationFactory } from '../debug-configuration.factory'; |
| 18 | +import { GDBTargetConfiguration } from '../gdbtarget-configuration'; |
18 | 19 | import { PyocdConfigurationProvider } from './pyocd-configuration-provider'; |
19 | 20 |
|
20 | 21 | describe('PyocdConfigurationProvider', () => { |
21 | 22 |
|
22 | | - it('resolveDebugConfigurationWithSubstitutedVariables', async () => { |
23 | | - const configProvider = new PyocdConfigurationProvider(); |
24 | | - const config = debugConfigurationFactory(); |
25 | | - const debugConfig = await configProvider.resolveDebugConfigurationWithSubstitutedVariables(undefined, config, undefined); |
26 | | - expect(debugConfig).toBeDefined(); |
| 23 | + describe('resolveDebugConfigurationWithSubstitutedVariables', () => { |
| 24 | + |
| 25 | + it('adds gdbserver to minimal configuration serverParameters', async () => { |
| 26 | + const configProvider = new PyocdConfigurationProvider(); |
| 27 | + const config = gdbTargetConfiguration({ |
| 28 | + target: targetConfigurationFactory(), |
| 29 | + }); |
| 30 | + const debugConfig = await configProvider.resolveDebugConfigurationWithSubstitutedVariables(undefined, config, undefined); |
| 31 | + expect(debugConfig).toBeDefined(); |
| 32 | + const gdbtargetConfig = debugConfig as GDBTargetConfiguration; |
| 33 | + expect(gdbtargetConfig?.target?.serverParameters).toContain('gdbserver'); |
| 34 | + expect(gdbtargetConfig?.target?.serverParameters).not.toContain('--port'); |
| 35 | + }); |
| 36 | + |
| 37 | + it('adds port to server parameters, gdbserver always gets added', async () => { |
| 38 | + const configProvider = new PyocdConfigurationProvider(); |
| 39 | + const config = gdbTargetConfiguration({ |
| 40 | + target: targetConfigurationFactory({ port: '4711' }), |
| 41 | + }); |
| 42 | + const debugConfig = await configProvider.resolveDebugConfigurationWithSubstitutedVariables(undefined, config, undefined); |
| 43 | + expect(debugConfig).toBeDefined(); |
| 44 | + const gdbtargetConfig = debugConfig as GDBTargetConfiguration; |
| 45 | + expect(gdbtargetConfig?.target?.serverParameters).toContain('gdbserver'); |
| 46 | + expect(gdbtargetConfig?.target?.serverParameters).toContain('--port'); |
| 47 | + expect(gdbtargetConfig?.target?.serverParameters).toContain('4711'); |
| 48 | + }); |
| 49 | + |
| 50 | + it('does not overwrite port in server parameters', async () => { |
| 51 | + const configProvider = new PyocdConfigurationProvider(); |
| 52 | + const config = gdbTargetConfiguration({ |
| 53 | + target: targetConfigurationFactory({ |
| 54 | + port: '4711', |
| 55 | + serverParameters: ['-port', '10815'], |
| 56 | + }), |
| 57 | + }); |
| 58 | + const debugConfig = await configProvider.resolveDebugConfigurationWithSubstitutedVariables(undefined, config, undefined); |
| 59 | + expect(debugConfig).toBeDefined(); |
| 60 | + const gdbtargetConfig = debugConfig as GDBTargetConfiguration; |
| 61 | + expect(gdbtargetConfig?.target?.serverParameters).toContain('--port'); |
| 62 | + expect(gdbtargetConfig?.target?.serverParameters).toContain('10815'); |
| 63 | + }); |
| 64 | + |
| 65 | + it.each([ |
| 66 | + { host: 'keep absolute path on Unix', pyocdPath: '/my/pyocd' }, |
| 67 | + { host: 'keep absolute path on Win', pyocdPath: 'C:\\my\\pyocd' }, |
| 68 | + ])('handles server path if absolute or adds absolute path for built-in', async ({ pyocdPath }) => { |
| 69 | + const configProvider = new PyocdConfigurationProvider(); |
| 70 | + const config = gdbTargetConfiguration({ |
| 71 | + target: targetConfigurationFactory({ |
| 72 | + server: pyocdPath |
| 73 | + }), |
| 74 | + }); |
| 75 | + const debugConfig = await configProvider.resolveDebugConfigurationWithSubstitutedVariables(undefined, config, undefined); |
| 76 | + expect(debugConfig).toBeDefined(); |
| 77 | + const gdbtargetConfig = debugConfig as GDBTargetConfiguration; |
| 78 | + expect(gdbtargetConfig?.target?.server).toContain(pyocdPath); |
| 79 | + }); |
27 | 80 | }); |
28 | 81 |
|
29 | 82 | }); |
0 commit comments