Inspector only enabled when specified#343
Conversation
52eb128 to
c7a41b4
Compare
src/agent/v8/debugapi.ts
Outdated
| const inspectorapi = require('./inspector-debugapi'); | ||
| debugApiConstructor = inspectorapi.InspectorDebugApi; | ||
| } else { | ||
| if (process.env.GCLOUD_USE_INSPECTOR) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
bin/run-test.sh
Outdated
| # Run test/coverage | ||
| run build/test | ||
|
|
||
| node_version_major=$(node -v | sed 's/v\([0-9]*\)\.[0-9]*.[0-9]*/\1/') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test_windows.js
Outdated
| const nodeVersion = /v(\d+\.\d+\.\d+)/.exec(process.version); | ||
| if (!nodeVersion || nodeVersion.length < 2) { | ||
| console.error('unable to get node version'); | ||
| } else if (semver.satisfies(nodeVersion[1], '>=8')) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test_windows.js
Outdated
| var mocha = new Mocha(); | ||
| var testDir = 'build/test'; | ||
| fs.readdirSync(testDir).filter(function(file) { | ||
| return file.substr(-3) === '.js'; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test_windows.js
Outdated
|
|
||
|
|
||
| var mocha = new Mocha(); | ||
| var testDir = 'build/test'; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test_windows.js
Outdated
|
|
||
| process.env.GCLOUD_PROJECT = 0 | ||
| process.env.CLOUD_DEBUG_ASSERTIONS = 1 | ||
|
|
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/agent/util/utils.ts
Outdated
| COULD_NOT_FIND_OUTPUT_FILE: | ||
| 'Could not determine the output file associated with the transpiled input file' | ||
| 'Could not determine the output file associated with the transpiled input file', | ||
| INSPECTOR_NOT_AVAILABLE: 'Inspector protocol only works for node 8+' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
bin/run-test.sh
Outdated
| @@ -32,6 +32,14 @@ function run { | |||
| # Run test/coverage | |||
| run build/test | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
bin/run-test.sh
Outdated
| node_version_major=$(node -p "require('semver').major(process.version)") | ||
| if test $node_version_major -ge 8 | ||
| then | ||
| echo 'Test with v8 Inspector' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test/test-v8debugapi.ts
Outdated
| }); | ||
| const logger = new common.logger({ levelLevel: config.logLevel } as any as LoggerOptions); | ||
|
|
||
| it('Verify the correct debugapi was constructed', (done) => { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test/test-v8debugapi.ts
Outdated
| }); | ||
| const logger = new common.logger({ levelLevel: config.logLevel } as any as LoggerOptions); | ||
|
|
||
| it('Verify the correct debugapi was constructed', (done) => { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| api = debugapi.create(logger, config, jsStats, mapper as SourceMapper.SourceMapper) as DebugApi; | ||
| if (process.env.GCLOUD_USE_INSPECTOR && semver.satisfies(process.version, '>=8')) { | ||
| const inspectorapi = require('../src/agent/v8/inspector-debugapi'); | ||
| assert.ok(api instanceof inspectorapi.InspectorDebugApi); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test_windows.js
Outdated
| @@ -0,0 +1,19 @@ | |||
| const spawn = require('child_process').spawn; | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test_windows.js
Outdated
|
|
||
| process.env.GCLOUD_PROJECT = 0 | ||
| process.env.CLOUD_DEBUG_ASSERTIONS = 1 | ||
| spawn(path.join('node_modules', '.bin', 'mocha.cmd'), |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test_windows.js
Outdated
| spawn(path.join('node_modules', '.bin', 'mocha.cmd'), | ||
| [ path.join('build', 'test'), '--timeout 4000', '--R' ], { | ||
| stdio : 'inherit' | ||
| }).on('close', function() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test_windows.js
Outdated
| console.log('Run test with Inspector'); | ||
| spawn(path.join('node_modules', '.bin', 'mocha.cmd'), | ||
| [ path.join('build', 'test'), '--timeout 4000', '--R' ], { | ||
| stdio : 'inherit' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
a3269ae to
8f660c0
Compare
| # run tests | ||
| - npm run build | ||
| - node_modules/.bin/mocha build/test --timeout 4000 --R | ||
| - SET GCLOUD_USE_INSPECTOR=1 |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
45f70c9 to
28a449f
Compare
test/test-v8debugapi.ts
Outdated
| const logger = new common.logger({ levelLevel: config.logLevel } as any as LoggerOptions); | ||
| let warnIsCalled = false; | ||
| logger.warn = function(_s: string) { | ||
| warnIsCalled = true; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
appveyor.yml
Outdated
| matrix: | ||
| # node.js | ||
| - nodejs_version: "4" | ||
|
|
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This PR ensures that inspector protocol will only be enabled if environmental variable GCLOUD_USE_INSPECTOR is set.
8196ec3 to
18b09ef
Compare
kjin
left a comment
There was a problem hiding this comment.
LGTM w/ minor comments. We should add a note about this in the README... though it's fine to leave that for the next PR.
bin/run-test.sh
Outdated
| @@ -32,6 +32,14 @@ function run { | |||
| # Run test/coverage | |||
| run build/test | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| const dummyapi = require('./dummy-debugapi'); | ||
| debugApiConstructor = dummyapi.DummyDebugApi; | ||
| } else if (semver.satisfies(nodeVersion[1], '>=8')) { | ||
| if (semver.satisfies(process.version, '>=8') && |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
18b09ef to
129fda7
Compare
a039b34 to
62912be
Compare
This PR ensures that inspector protocol will only be enabled if
environmental variable GCLOUD_USE_INSPECTOR is set.