-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathlaunch.spec.ts
117 lines (106 loc) · 3.93 KB
/
launch.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*********************************************************************
* Copyright (c) 2018 Ericsson and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*********************************************************************/
import { expect } from 'chai';
import * as path from 'path';
import * as os from 'os';
import { LaunchRequestArguments } from '../types/session';
import { CdtDebugClient } from './debugClient';
import {
fillDefaults,
gdbNonStop,
isRemoteTest,
standardBeforeEach,
testProgramsDir,
} from './utils';
describe('launch', function () {
let dc: CdtDebugClient;
const emptyProgram = path.join(testProgramsDir, 'empty');
const emptySpaceProgram = path.join(testProgramsDir, 'empty space');
const emptySrc = path.join(testProgramsDir, 'empty.c');
const emptySpaceSrc = path.join(testProgramsDir, 'empty space.c');
const unicodeProgram = path.join(testProgramsDir, 'bug275-测试');
// the name of this file is short enough to work around https://sourceware.org/bugzilla/show_bug.cgi?id=30618
const unicodeSrc = path.join(testProgramsDir, 'bug275-测试.c');
beforeEach(async function () {
dc = await standardBeforeEach();
});
afterEach(async function () {
await dc.stop();
});
it('can launch and hit a breakpoint', async function () {
await dc.hitBreakpoint(
fillDefaults(this.test, {
program: emptyProgram,
} as LaunchRequestArguments),
{
path: emptySrc,
line: 3,
}
);
});
it('reports an error when specifying a non-existent binary', async function () {
const errorMessage = await new Promise<Error>((resolve, reject) => {
dc.launchRequest(
fillDefaults(this.test, {
program: '/does/not/exist',
} as LaunchRequestArguments)
)
.then(reject)
.catch(resolve);
});
// When launching a remote test gdbserver generates the error which is not exactly the same
// as GDB's error
expect(errorMessage.message).to.satisfy(
(msg: string) =>
msg.includes('/does/not/exist') &&
(msg.includes('The system cannot find the path specified') ||
msg.includes('No such file or directory') ||
msg.includes('not found'))
);
});
it('works with a space in file names', async function () {
await dc.hitBreakpoint(
fillDefaults(this.test, {
program: emptySpaceProgram,
} as LaunchRequestArguments),
{
path: emptySpaceSrc,
line: 3,
}
);
});
it('works with unicode in file names', async function () {
if (!gdbNonStop && os.platform() === 'win32' && isRemoteTest) {
// on windows remote tests don't support the unicode in file name (except for non-stop which seems to)
this.skip();
}
await dc.hitBreakpoint(
fillDefaults(this.test, {
program: unicodeProgram,
} as LaunchRequestArguments),
{
path: unicodeSrc,
line: 3,
}
);
});
it('provides a decent error if program is omitted', async function () {
const errorMessage = await new Promise<Error>((resolve, reject) => {
dc.launchRequest(
fillDefaults(this.test, {} as LaunchRequestArguments)
)
.then(reject)
.catch(resolve);
});
expect(errorMessage.message).to.satisfy((msg: string) =>
msg.includes('program must be specified')
);
});
});