Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 40365fb

Browse files
Enable all compiler options (#321)
1 parent 29ba46b commit 40365fb

20 files changed

+486
-310
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@types/mocha": "^2.2.41",
3131
"@types/nock": "^8.2.1",
3232
"@types/node": "^7.0.18",
33+
"@types/request": "^2.0.0",
3334
"@types/semver": "^5.3.32",
3435
"@types/source-map": "^0.5.0",
3536
"changelog-maker": "^2.2.2",

system-test/test-controller.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ describe('Controller', function() {
5050
// TODO: Only 1 parameter is expected. Fix this.
5151
(assert as any).ifError(err, 'should be able to register successfully');
5252
assert.ok(body);
53-
assert.ok(body.debuggee);
54-
assert.ok(body.debuggee.id);
53+
// TODO: Handle the case when body is undefined
54+
assert.ok((body as any).debuggee);
55+
assert.ok((body as any).debuggee.id);
5556
done();
5657
});
5758
});
@@ -66,15 +67,18 @@ describe('Controller', function() {
6667
// TODO: Determine if statusMessage should be made optional.
6768
statusMessage: null
6869
});
69-
controller.register(debuggee, function(err, body) {
70+
// TODO: Determine if the body parameter should be used.
71+
controller.register(debuggee, function(err, _body) {
7072
// TODO: Only 1 parameter is expected. Fix this.
7173
(assert as any).ifError(err, 'should be able to register successfully');
7274

73-
controller.listBreakpoints(debuggee, function(err, response, body) {
75+
// TODO: Determine if the response parameter should be used.
76+
controller.listBreakpoints(debuggee, function(err, _response, body) {
7477
// TODO: Only 1 parameter is expected. Fix this.
7578
(assert as any).ifError(err, 'should successfully list breakpoints');
7679
assert.ok(body);
77-
assert.ok(body.nextWaitToken);
80+
// TODO: Handle the case when body is undefined
81+
assert.ok((body as any).nextWaitToken);
7882
done();
7983
});
8084
});
@@ -91,24 +95,28 @@ describe('Controller', function() {
9195
// TODO: Determine if statusMessage should be made optional.
9296
statusMessage: null
9397
});
94-
controller.register(debuggee, function(err, body) {
98+
// TODO: Determine if the body parameter should be used.
99+
controller.register(debuggee, function(err, _body) {
95100
// TODO: Only 1 parameter is expected. Fix this.
96101
(assert as any).ifError(err, 'should be able to register successfully');
97102

98103
// First list should set the wait token
99-
controller.listBreakpoints(debuggee, function(err, response, body) {
104+
// TODO: Determine if the response parameter should be used.
105+
controller.listBreakpoints(debuggee, function(err, _response, body) {
100106
// TODO: Only 1 parameter is expected. Fix this.
101107
(assert as any).ifError(err, 'should successfully list breakpoints');
102108
assert.ok(body);
103-
assert.ok(body.nextWaitToken);
109+
// TODO: Handle the case when body is undefined
110+
assert.ok((body as any).nextWaitToken);
104111
// Second list should block until the wait timeout
105-
controller.listBreakpoints(debuggee, function(err, response, body) {
112+
// TODO: Determine if the response parameter should be used.
113+
controller.listBreakpoints(debuggee, function(err, _response, body) {
106114
// TODO: Only 1 parameter is expected. Fix this.
107115
(assert as any).ifError(err, 'should successfully list breakpoints');
108116
assert.ok(body);
109-
assert.ok(body.nextWaitToken);
117+
assert.ok((body as any).nextWaitToken);
110118
// waitExpired will only be set if successOnTimeout was given correctly
111-
assert.ok(body.waitExpired);
119+
assert.ok((body as any).waitExpired);
112120
done();
113121
});
114122
});

system-test/test-e2e.ts

Lines changed: 57 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
* limitations under the License.
1515
*/
1616

17+
import * as apiTypes from '../src/types/api-types';
18+
1719
import * as assert from 'assert';
1820
import * as util from 'util';
1921
import * as _ from 'lodash'; // for _.find. Can't use ES6 yet.
2022
import * as cp from 'child_process';
2123
import * as semver from 'semver';
2224
const promisifyAll = require('@google-cloud/common').util.promisifyAll;
2325
import {Debug} from '../src/debug';
26+
import {Debuggee} from '../src/debuggee';
2427
import {Debugger} from '../test/debugger';
2528

2629
const CLUSTER_WORKERS = 3;
@@ -29,18 +32,24 @@ const CLUSTER_WORKERS = 3;
2932
const FILENAME = 'build/test/fixtures/fib.js';
3033

3134
const delay = function(delayTimeMS: number): Promise<void> {
32-
return new Promise(function(resolve, reject) {
35+
// TODO: Determine if the reject parameter should be used.
36+
return new Promise(function(resolve, _reject) {
3337
setTimeout(resolve, delayTimeMS);
3438
});
3539
};
3640

41+
interface Child {
42+
transcript: string;
43+
process?: cp.ChildProcess;
44+
}
45+
3746
// This test could take up to 70 seconds.
3847
describe('@google-cloud/debug end-to-end behavior', function () {
3948
let api: Debugger;
4049

41-
let debuggeeId: string;
42-
let projectId: string;
43-
let children = [];
50+
let debuggeeId: string|null;
51+
let projectId: string|null;
52+
let children: Child[] = [];
4453

4554
before(function() {
4655
promisifyAll(Debugger);
@@ -53,7 +62,8 @@ describe('@google-cloud/debug end-to-end behavior', function () {
5362
let numChildrenReady = 0;
5463

5564
// Process a status message sent from a child process.
56-
const handler = function(c) {
65+
// TODO: Determine if this type signature is correct
66+
const handler = function(c: { error: Error|null, debuggeeId: string, projectId: string}) {
5767
console.log(c);
5868
if (c.error) {
5969
reject(new Error('A child reported the following error: ' + c.error));
@@ -80,8 +90,8 @@ describe('@google-cloud/debug end-to-end behavior', function () {
8090
// Handle stdout/stderr output from a child process. More specifically,
8191
// write the child process's output to a transcript.
8292
// Each child has its own transcript.
83-
const stdoutHandler = function(index) {
84-
return function(chunk) {
93+
const stdoutHandler = function(index: number) {
94+
return function(chunk: string) {
8595
children[index].transcript += chunk;
8696
};
8797
};
@@ -111,12 +121,13 @@ describe('@google-cloud/debug end-to-end behavior', function () {
111121
// Create a promise for each child that resolves when that child exits.
112122
const childExitPromises = children.map(function (child) {
113123
console.log(child.transcript);
114-
child.process.kill();
124+
// TODO: Handle the case when child.process is undefined
125+
(child.process as any).kill();
115126
return new Promise(function(resolve, reject) {
116127
const timeout = setTimeout(function() {
117128
reject(new Error('A child process failed to exit.'));
118129
}, 3000);
119-
child.process.on('exit', function() {
130+
(child.process as any).on('exit', function() {
120131
clearTimeout(timeout);
121132
resolve();
122133
});
@@ -134,39 +145,41 @@ describe('@google-cloud/debug end-to-end behavior', function () {
134145
this.timeout(90 * 1000);
135146
// Kick off promise chain by getting a list of debuggees
136147
// TODO: Determine how to properly specify the signature of listDebuggees
137-
return (api as any).listDebuggees(projectId).then(function(results) {
148+
// TODO: Determine if this is the correct signature for `then`
149+
return (api as any).listDebuggees(projectId).then(function(results: { [index: number]: Debuggee[] }) {
138150
// Check that the debuggee created in this test is among the list of
139151
// debuggees, then list its breakpoints
140-
141-
const debuggees = results[0];
152+
153+
const debuggees: Debuggee[] = results[0];
142154

143155
console.log('-- List of debuggees\n',
144156
util.inspect(debuggees, { depth: null}));
145157
assert.ok(debuggees, 'should get a valid ListDebuggees response');
146-
// TODO: Fix this cast to any.
147-
const result = _.find(debuggees, function(d: any) {
158+
const result = _.find(debuggees, function(d: Debuggee) {
148159
return d.id === debuggeeId;
149160
});
150161
assert.ok(result, 'should find the debuggee we just registered');
151162
// TODO: Determine how to properly specify the signature of listDebuggees
152163
return (api as any).listBreakpoints(debuggeeId);
153-
}).then(function(results) {
164+
// TODO: Determine if this type signature is correct.
165+
}).then(function(results: { [index: number]: apiTypes.Breakpoint[]}) {
154166
// Delete every breakpoint
155167

156-
const breakpoints = results[0];
168+
const breakpoints: apiTypes.Breakpoint[] = results[0];
157169

158170
console.log('-- List of breakpoints\n', breakpoints);
159171

160-
const promises = breakpoints.map(function(breakpoint) {
172+
const promises = breakpoints.map(function(breakpoint: apiTypes.Breakpoint) {
161173
// TODO: Determine how to properly specify the signature of listDebuggees
162174
return (api as any).deleteBreakpoint(debuggeeId, breakpoint.id);
163175
});
164176

165177
return Promise.all(promises);
166-
}).then(function(results) {
178+
// TODO: Determine if this type signature is correct
179+
}).then(function(results: apiTypes.Breakpoint[]) {
167180
// Set a breakpoint at which the debugger should write to a log
168181

169-
results.map(function(result) {
182+
results.map(function(result: apiTypes.Breakpoint) {
170183
assert.equal(result, '');
171184
});
172185
console.log('-- deleted');
@@ -181,7 +194,8 @@ describe('@google-cloud/debug end-to-end behavior', function () {
181194
expressions: ['o'],
182195
log_message_format: 'o is: $0'
183196
});
184-
}).then(function(results) {
197+
// TODO: Determine if this type signature is correct.
198+
}).then(function(results: apiTypes.Breakpoint[]) {
185199
// Check that the breakpoint was set, and then wait for the log to be
186200
// written to
187201

@@ -190,14 +204,18 @@ describe('@google-cloud/debug end-to-end behavior', function () {
190204
assert.ok(breakpoint, 'should have set a breakpoint');
191205
assert.ok(breakpoint.id, 'breakpoint should have an id');
192206
assert.ok(breakpoint.location, 'breakpoint should have a location');
193-
assert.strictEqual(breakpoint.location.path, FILENAME);
207+
// TODO: Handle the case when breakpoint.location is undefined
208+
assert.strictEqual((breakpoint.location as any).path, FILENAME);
194209

195210
console.log('-- waiting before checking if the log was written');
196211
return Promise.all([breakpoint, delay(10 * 1000)]);
197-
}).then(function(results) {
212+
// TODO: Determine if the results parameter should be used.
213+
}).then(function(_results: apiTypes.Breakpoint[]) {
214+
198215
// Check the contents of the log, but keep the original breakpoint.
199216

200-
const breakpoint = results[0];
217+
// TODO: This is never used. Determine if it should be used.
218+
//const breakpoint = results[0];
201219

202220
children.forEach(function(child, index) {
203221
assert(child.transcript.indexOf('o is: {"a":[1,"hi",true]}') !== -1,
@@ -216,7 +234,7 @@ describe('@google-cloud/debug end-to-end behavior', function () {
216234
expressions: ['process'], // Process for large variable
217235
condition: 'n === 10'
218236
});
219-
}).then(function(results) {
237+
}).then(function(results: apiTypes.Breakpoint[]) {
220238
// Check that the breakpoint was set, and then wait for the breakpoint to
221239
// be hit
222240

@@ -226,19 +244,20 @@ describe('@google-cloud/debug end-to-end behavior', function () {
226244
assert.ok(breakpoint, 'should have set a breakpoint');
227245
assert.ok(breakpoint.id, 'breakpoint should have an id');
228246
assert.ok(breakpoint.location, 'breakpoint should have a location');
229-
assert.strictEqual(breakpoint.location.path, FILENAME);
247+
// TODO: Handle the case when breakpoint.location is undefined
248+
assert.strictEqual((breakpoint.location as any).path, FILENAME);
230249

231250
console.log('-- waiting before checking if breakpoint was hit');
232251
return Promise.all([breakpoint, delay(10 * 1000)]);
233-
}).then(function(results) {
252+
}).then(function(results: apiTypes.Breakpoint[]) {
234253
// Get the breakpoint
235254

236255
const breakpoint = results[0];
237256

238257
console.log('-- now checking if the breakpoint was hit');
239258
// TODO: Determine how to properly specify the signature of listDebuggees
240259
return (api as any).getBreakpoint(debuggeeId, breakpoint.id);
241-
}).then(function(results) {
260+
}).then(function(results: apiTypes.Breakpoint[]) {
242261
// Check that the breakpoint was hit and contains the correct information,
243262
// which ends the test
244263

@@ -260,7 +279,8 @@ describe('@google-cloud/debug end-to-end behavior', function () {
260279
arg = _.find(top.arguments, {name: 'n'});
261280
}
262281
assert.ok(arg, 'should find the n argument');
263-
assert.strictEqual(arg.value, '10');
282+
// TODO: Handle the case when arg is undefined
283+
assert.strictEqual((arg as any).value, '10');
264284
console.log('-- checking log point was hit again');
265285
children.forEach(function(child) {
266286
const count = (child.transcript
@@ -291,7 +311,8 @@ describe('@google-cloud/debug end-to-end behavior', function () {
291311
this.timeout(15 * 1000);
292312
// Kick off promise chain by getting a list of debuggees
293313
// TODO: Determine how to properly specify the signature of listDebuggees
294-
return (api as any).listDebuggees(projectId).then(function(results) {
314+
// TODO: Determine if this is the correct signature for then
315+
return (api as any).listDebuggees(projectId).then(function(results: { [index: number]: Debuggee[] }) {
295316
// Check that the debuggee created in this test is among the list of
296317
// debuggees, then list its breakpoints
297318

@@ -308,10 +329,10 @@ describe('@google-cloud/debug end-to-end behavior', function () {
308329

309330
// TODO: Determine how to properly specify the signature of listDebuggees
310331
return (api as any).listBreakpoints(debuggeeId);
311-
}).then(function(results) {
332+
}).then(function(results: { [index: number]: apiTypes.Breakpoint[] }) {
312333
// Delete every breakpoint
313334

314-
const breakpoints = results[0];
335+
const breakpoints: apiTypes.Breakpoint[] = results[0];
315336

316337
console.log('-- List of breakpoints\n', breakpoints);
317338

@@ -321,7 +342,7 @@ describe('@google-cloud/debug end-to-end behavior', function () {
321342
});
322343

323344
return Promise.all(promises);
324-
}).then(function(results) {
345+
}).then(function(results: Promise<void>[]) {
325346
// Set a breakpoint at which the debugger should write to a log
326347

327348
results.map(function(result) {
@@ -339,19 +360,20 @@ describe('@google-cloud/debug end-to-end behavior', function () {
339360
expressions: ['o'],
340361
log_message_format: 'o is: $0'
341362
});
342-
}).then(function(results) {
363+
}).then(function(results: apiTypes.Breakpoint[]) {
343364
// Check that the breakpoint was set, and then wait for the log to be
344365
// written to
345366
const breakpoint = results[0];
346367

347368
assert.ok(breakpoint, 'should have set a breakpoint');
348369
assert.ok(breakpoint.id, 'breakpoint should have an id');
349370
assert.ok(breakpoint.location, 'breakpoint should have a location');
350-
assert.strictEqual(breakpoint.location.path, FILENAME);
371+
// TODO: Handle the case when breakpoint.location is undefined
372+
assert.strictEqual((breakpoint.location as any).path, FILENAME);
351373

352374
console.log('-- waiting before checking if the log was written');
353375
return Promise.all([breakpoint, delay(10 * 1000)]);
354-
}).then(function(results) {
376+
}).then(function(results: apiTypes.Breakpoint[]) {
355377
// Check that the contents of the log is correct
356378

357379
const breakpoint = results[0];

test/auth-request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import * as http from 'http';
2020

2121
// TODO: Make the type of `options` more precise
2222
export default function(options: any, callback: (err: Error, body: any, response: http.ServerResponse) => void) {
23-
request(options, function(err, response, body) {
23+
request(options, function(err: Error, response: http.ServerResponse, body: any) {
2424
callback(err, body, response);
2525
});
2626
};

test/debugger.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const qs: { parse: (qs: any, sep?: string, eq?: string,
3030
options?: { maxKeys?: number }) => any,
3131
stringify: (obj: object|string|boolean|number, sep?: string,
3232
eq?: string, name?: string) => string} = require('querystring');
33-
import * as util from 'util';
3433

3534
/** @const {string} Cloud Debug API endpoint */
3635
const API = 'https://clouddebugger.googleapis.com/v2/debugger';

test/misc/bench.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const fib = require('./bench-code.js');
2626
const logger = new Logger(config.logLevel);
2727
assert.ok(v8debugapi.init(logger, config));
2828

29-
function bench(message, f) {
29+
function bench(message: any, f: any) {
3030
let t = process.hrtime();
3131
f();
3232
t = process.hrtime(t);

0 commit comments

Comments
 (0)