1717import * as stackdriver from '../src/types/stackdriver' ;
1818import { DebugAgentConfig } from '../src/agent/config' ;
1919import { Debuggee } from '../src/debuggee' ;
20+ import * as semver from 'semver' ;
2021
2122import * as _ from 'lodash' ;
2223import * as path from 'path' ;
@@ -29,6 +30,7 @@ import * as dns from 'dns';
2930import * as extend from 'extend' ;
3031const metadata : { project : any , instance : any } = require ( 'gcp-metadata' ) ;
3132import { Debug } from '../src/client/stackdriver/debug' ;
33+ import * as utils from '../src/agent/util/utils'
3234
3335const DEBUGGEE_ID = 'bar' ;
3436const API = 'https://clouddebugger.googleapis.com' ;
@@ -289,16 +291,19 @@ describe('Debuglet', function() {
289291 } ) ;
290292
291293 describe ( 'setup' , function ( ) {
292- before ( function ( ) { oldGP = process . env . GCLOUD_PROJECT ; } ) ;
294+ before ( function ( ) {
295+ oldGP = process . env . GCLOUD_PROJECT ;
296+ } ) ;
293297
294298 after ( function ( ) { process . env . GCLOUD_PROJECT = oldGP ; } ) ;
295-
296299 beforeEach ( function ( ) {
297300 delete process . env . GCLOUD_PROJECT ;
298301 nocks . oauth2 ( ) ;
299302 } ) ;
300303
301- afterEach ( function ( ) { nock . cleanAll ( ) ; } ) ;
304+ afterEach ( function ( ) {
305+ nock . cleanAll ( ) ;
306+ } ) ;
302307
303308 it ( 'should merge config correctly' , function ( ) {
304309 const testValue = 2 * defaultConfig . capture . maxExpandFrames ;
@@ -315,6 +320,40 @@ describe('Debuglet', function() {
315320 assert . deepEqual ( mergedConfig , compareConfig ) ;
316321 } ) ;
317322
323+ it ( 'should elaborate on inspector warning on 32 bit but not on 64 bit' ,
324+ function ( done ) {
325+ const projectId = '11020304f2934-a' ;
326+ const debug = new Debug (
327+ { projectId : projectId , credentials : fakeCredentials } ) ;
328+ const debuglet = new Debuglet ( debug , defaultConfig ) ;
329+ let logText = '' ;
330+ debuglet . logger_ . info = function ( s : string ) {
331+ logText += s ;
332+ } ;
333+ nocks . projectId ( 'project-via-metadata' ) ;
334+ const scope = nock ( API )
335+ . post ( REGISTER_PATH )
336+ . reply ( 200 , { debuggee : { id : DEBUGGEE_ID } } ) ;
337+
338+ debuglet . once ( 'registered' , function ( id : string ) {
339+ assert . equal ( id , DEBUGGEE_ID ) ;
340+ // TODO: Handle the case where debuglet.debuggee is undefined
341+ assert . equal ( ( debuglet . debuggee_ as Debuggee ) . project , projectId ) ;
342+ const arch = process . arch ;
343+ if ( semver . satisfies ( process . version , '>=8.5' ) &&
344+ ( arch === 'ia32' || arch === 'x86' ) ) {
345+ assert ( logText . includes ( utils . messages . ASYNC_TRACES_WARNING ) ) ;
346+ } else {
347+ assert ( ! logText . includes ( utils . messages . ASYNC_TRACES_WARNING ) ) ;
348+ }
349+ debuglet . stop ( ) ;
350+ scope . done ( ) ;
351+ done ( ) ;
352+ } ) ;
353+
354+ debuglet . start ( ) ;
355+ } ) ;
356+
318357 it ( 'should not start when projectId is not available' , function ( done ) {
319358 const savedGetProjectId = Debuglet . getProjectId ;
320359 Debuglet . getProjectId = ( ) => {
0 commit comments