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

Commit a00ce2a

Browse files
authored
Make all tests runnable together (#218)
PR-URL: #218
1 parent 474c2dc commit a00ce2a

14 files changed

+73
-62
lines changed

appveyor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ install:
1818
test_script:
1919
# run tests
2020
- ps: node_modules/.bin/mocha test --timeout 4000 --R
21-
- ps: ForEach ($test in Get-ChildItem test/standalone/test-*.js) { node_modules/.bin/mocha $test --timeout 4000 --R; if ($lastexitcode -ne 0) { exit 1 } }
2221

2322
# Don't actually build using MSBuild
2423
build: off

bin/run-test.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ function run {
3131

3232
# Run test/coverage
3333
run test
34-
for test in test/standalone/test-*.js ;
35-
do
36-
run "${test}"
37-
done
3834

3935
# Conditionally publish coverage
4036
if [ "$cover" ]; then

src/agent/v8debugapi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var formatInterval = function(msg, interval) {
5959

6060
var singleton;
6161
module.exports.create = function(logger_, config_, jsFiles_, sourcemapper_) {
62-
if (singleton) {
62+
if (singleton && !config_.forceNewAgent_) {
6363
return singleton;
6464
}
6565

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ var debuglet;
8383
* debug.startAgent();
8484
*/
8585
Debug.prototype.startAgent = function(config) {
86-
if (debuglet) {
86+
// config.forceNewAgent_ is for testing purposes only.
87+
if (debuglet && !config.forceNewAgent_) {
8788
throw new Error('Debug Agent has already been started');
8889
}
8990

test/test-debuglet.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,10 @@ describe('Debuglet', function() {
254254
it('should error if a package.json doesn\'t exist', function(done) {
255255
var debug = require('..')(
256256
{projectId: 'fake-project', credentials: fakeCredentials});
257-
var config = extend({}, defaultConfig, {workingDirectory: __dirname});
257+
var config = extend({}, defaultConfig, {
258+
workingDirectory: __dirname,
259+
forceNewAgent_: true
260+
});
258261
var debuglet = new Debuglet(debug, config);
259262

260263
debuglet.once('initError', function(err) {
@@ -493,7 +496,10 @@ describe('Debuglet', function() {
493496
it('should expire stale breakpoints', function(done) {
494497
var debug = require('..')(
495498
{projectId: 'fake-project', credentials: fakeCredentials});
496-
var config = extend({}, defaultConfig, {breakpointExpirationSec: 1});
499+
var config = extend({}, defaultConfig, {
500+
breakpointExpirationSec: 1,
501+
forceNewAgent_: true
502+
});
497503
this.timeout(6000);
498504

499505
var scope = nock(API)
@@ -542,7 +548,8 @@ describe('Debuglet', function() {
542548
{projectId: 'fake-project', credentials: fakeCredentials});
543549
var config = extend({}, defaultConfig, {
544550
breakpointExpirationSec: 1,
545-
breakpointUpdateIntervalSec: 1
551+
breakpointUpdateIntervalSec: 1,
552+
forceNewAgent_: true
546553
});
547554
this.timeout(6000);
548555

test/standalone/test-duplicate-expressions.js renamed to test/test-duplicate-expressions.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ var breakpointInFoo = {
2828

2929
var assert = require('assert');
3030
var extend = require('extend');
31-
var v8debugapi = require('../../src/agent/v8debugapi.js');
31+
var v8debugapi = require('../src/agent/v8debugapi.js');
3232
var common = require('@google-cloud/common');
33-
var defaultConfig = require('../../src/agent/config.js');
34-
var SourceMapper = require('../../src/agent/sourcemapper.js');
35-
var scanner = require('../../src/agent/scanner.js');
33+
var defaultConfig = require('../src/agent/config.js');
34+
var SourceMapper = require('../src/agent/sourcemapper.js');
35+
var scanner = require('../src/agent/scanner.js');
3636
var path = require('path');
3737

3838
function stateIsClean(api) {
@@ -45,7 +45,8 @@ function stateIsClean(api) {
4545

4646
describe('v8debugapi', function() {
4747
var config = extend({}, defaultConfig, {
48-
workingDirectory: path.join(process.cwd(), 'test', 'standalone')
48+
workingDirectory: path.join(process.cwd(), 'test'),
49+
forceNewAgent_: true
4950
});
5051
var logger = common.logger({ logLevel: config.logLevel });
5152
var api = null;

test/standalone/test-duplicate-nested-expressions.js renamed to test/test-duplicate-nested-expressions.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626

2727
var assert = require('assert');
2828
var extend = require('extend');
29-
var v8debugapi = require('../../src/agent/v8debugapi.js');
29+
var v8debugapi = require('../src/agent/v8debugapi.js');
3030
var common = require('@google-cloud/common');
31-
var defaultConfig = require('../../src/agent/config.js');
32-
var SourceMapper = require('../../src/agent/sourcemapper.js');
33-
var scanner = require('../../src/agent/scanner.js');
31+
var defaultConfig = require('../src/agent/config.js');
32+
var SourceMapper = require('../src/agent/sourcemapper.js');
33+
var scanner = require('../src/agent/scanner.js');
3434
var path = require('path');
3535
var semver = require('semver');
3636

@@ -44,7 +44,8 @@ function stateIsClean(api) {
4444

4545
describe('v8debugapi', function() {
4646
var config = extend({}, defaultConfig, {
47-
workingDirectory: path.join(process.cwd(), 'test', 'standalone')
47+
workingDirectory: path.join(process.cwd(), 'test'),
48+
forceNewAgent_: true
4849
});
4950
var logger = common.logger({ logLevel: config.logLevel });
5051
var api = null;

test/standalone/test-env-relative-repository-path.js renamed to test/test-env-relative-repository-path.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ var path = require('path');
2121
process.env.GCLOUD_PROJECT = 0;
2222

2323
var assert = require('assert');
24-
var agent = require('../..')();
24+
var agent = require('..')();
2525
var api;
26-
var h = require('../fixtures/a/hello.js');
26+
var h = require('./fixtures/a/hello.js');
2727

2828
describe('repository relative paths', function() {
2929

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
var assert = require('assert');
1919
var extend = require('extend');
20-
var v8debugapi = require('../../src/agent/v8debugapi.js');
20+
var v8debugapi = require('../src/agent/v8debugapi.js');
2121
var common = require('@google-cloud/common');
22-
var defaultConfig = require('../../src/agent/config.js');
23-
var SourceMapper = require('../../src/agent/sourcemapper.js');
24-
var scanner = require('../../src/agent/scanner.js');
22+
var defaultConfig = require('../src/agent/config.js');
23+
var SourceMapper = require('../src/agent/sourcemapper.js');
24+
var scanner = require('../src/agent/scanner.js');
2525
var path = require('path');
2626
var semver = require('semver');
2727

@@ -37,7 +37,8 @@ function stateIsClean(api) {
3737

3838
describe('v8debugapi', function() {
3939
var config = extend({}, defaultConfig, {
40-
workingDirectory: path.join(process.cwd(), 'test')
40+
workingDirectory: path.join(process.cwd(), 'test'),
41+
forceNewAgent_: true
4142
});
4243
var logger = common.logger({ logLevel: config.logLevel });
4344
var api = null;
@@ -50,7 +51,7 @@ describe('v8debugapi', function() {
5051
this.skip();
5152
return;
5253
}
53-
foo = require('../fixtures/fat-arrow.js');
54+
foo = require('./fixtures/fat-arrow.js');
5455
});
5556
beforeEach(function(done) {
5657
if (!api) {
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ process.env.GCLOUD_DIAGNOSTICS_CONFIG = 'test/fixtures/test-config.js';
2424
var assert = require('assert');
2525
var extend = require('extend');
2626
var common = require('@google-cloud/common');
27-
var v8debugapi = require('../../src/agent/v8debugapi.js');
28-
var SourceMapper = require('../../src/agent/sourcemapper.js');
29-
var scanner = require('../../src/agent/scanner.js');
30-
var defaultConfig = require('../../src/agent/config.js');
27+
var v8debugapi = require('../src/agent/v8debugapi.js');
28+
var SourceMapper = require('../src/agent/sourcemapper.js');
29+
var scanner = require('../src/agent/scanner.js');
30+
var defaultConfig = require('../src/agent/config.js');
3131
var api;
3232

3333
var breakpointInFoo = {
@@ -36,7 +36,9 @@ var breakpointInFoo = {
3636
};
3737

3838
describe('maxDataSize', function() {
39-
var config = extend({}, defaultConfig);
39+
var config = extend({}, defaultConfig, {
40+
forceNewAgent_: true
41+
});
4042

4143
before(function(done) {
4244
if (!api) {

0 commit comments

Comments
 (0)