@@ -36,6 +36,7 @@ var logModule = require('@google/cloud-diagnostics-common').logger;
3636var config = require ( '../config.js' ) ;
3737var StatusMessage = require ( '../lib/apiclasses.js' ) . StatusMessage ;
3838var scanner = require ( '../lib/scanner.js' ) ;
39+ var path = require ( 'path' ) ;
3940
4041function stateIsClean ( api ) {
4142 assert . equal ( api . numBreakpoints_ ( ) , 0 ,
@@ -107,7 +108,7 @@ function validateBreakpoint(breakpoint) {
107108}
108109
109110describe ( 'v8debugapi' , function ( ) {
110- config . workingDirectory = process . cwd ( ) + '/ test';
111+ config . workingDirectory = path . join ( process . cwd ( ) , ' test') ;
111112 var logger = logModule . create ( config . logLevel ) ;
112113 var api = null ;
113114
@@ -159,7 +160,8 @@ describe('v8debugapi', function() {
159160 it ( 'should set error for breakpoint in non-js files' ,
160161 function ( done ) {
161162 require ( './fixtures/key-bad.json' ) ;
162- var bp = { id : 0 , location : { line : 1 , path : 'fixtures/key-bad.json' } } ;
163+ var bp = { id : 0 , location : { line : 1 , path : path . join ( 'fixtures' ,
164+ 'key-bad.json' ) } } ;
163165 api . set ( bp , function ( err ) {
164166 assert . ok ( err , 'should return an error' ) ;
165167 assert . ok ( bp . status ) ;
@@ -173,7 +175,8 @@ describe('v8debugapi', function() {
173175 it ( 'should disambiguate incorrect path if filename is unique' ,
174176 function ( done ) {
175177 require ( './fixtures/foo.js' ) ;
176- var bp = { id : 0 , location : { line : 1 , path : '/test/foo.js' } } ;
178+ var bp = { id : 0 , location : { line : 1 , path : path . join ( path . sep , 'test' ,
179+ 'foo.js' ) } } ;
177180 api . set ( bp , function ( err ) {
178181 assert . ifError ( err ) ;
179182 api . clear ( bp ) ;
@@ -185,7 +188,8 @@ describe('v8debugapi', function() {
185188 function ( done ) {
186189 require ( './fixtures/foo.js' ) ;
187190 // hello.js is not unique but a/hello.js is.
188- var bp = { id : 0 , location : { line : 1 , path : '/Server/a/hello.js' } } ;
191+ var bp = { id : 0 , location : { line : 1 , path : path . join ( path . sep , 'Server' ,
192+ 'a' , 'hello.js' ) } } ;
189193 api . set ( bp , function ( err ) {
190194 assert . ifError ( err ) ;
191195 api . clear ( bp ) ;
@@ -235,7 +239,7 @@ describe('v8debugapi', function() {
235239 require ( './fixtures/foo.js' ) ;
236240 var bp = {
237241 id : 'non-existent line' ,
238- location : { path : './ fixtures/ foo.js', line : 500 }
242+ location : { path : path . join ( '.' , ' fixtures' , ' foo.js') , line : 500 }
239243 } ;
240244 api . set ( bp , function ( err ) {
241245 assert . ok ( err ) ;
@@ -316,13 +320,19 @@ describe('v8debugapi', function() {
316320
317321 describe ( 'path normalization' , function ( ) {
318322 var breakpoints = [
319- { id : 'path0' , location : { line : 4 , path : '/test/test-v8debugapi.js' } } ,
320- { id : 'path1' , location : { line : 4 , path : 'test/test-v8debugapi.js' } } ,
323+ { id : 'path0' , location : { line : 4 , path : path . join ( path . sep , 'test' ,
324+ 'test-v8debugapi.js' ) } } ,
325+ { id : 'path1' , location : { line : 4 , path : path . join ( 'test' ,
326+ 'test-v8debugapi.js' ) } } ,
321327 { id : 'path2' , location : { line : 4 , path : __filename } } ,
322- { id : 'with . in path' , location : { path : 'test/./test-v8debugapi.js' , line : 4 } } ,
323- { id : 'with . in path' , location : { path : './test-v8debugapi.js' , line : 4 } } ,
324- { id : 'with .. in path' , location : { path : 'test/../test-v8debugapi.js' , line : 4 } } ,
325- { id : 'with .. in path' , location : { path : '../test/test-v8debugapi.js' , line : 4 } }
328+ { id : 'with . in path' , location : { path : path . join ( 'test' , '.' ,
329+ 'test-v8debugapi.js' ) , line : 4 } } ,
330+ { id : 'with . in path' , location : { path : path . join ( '.' ,
331+ 'test-v8debugapi.js' ) , line : 4 } } ,
332+ { id : 'with .. in path' , location : { path : path . join ( 'test' , '..' ,
333+ 'test-v8debugapi.js' ) , line : 4 } } ,
334+ { id : 'with .. in path' , location : { path : path . join ( '..' , 'test' ,
335+ 'test-v8debugapi.js' ) , line : 4 } }
326336 ] ;
327337
328338 breakpoints . forEach ( function ( bp ) {
@@ -590,8 +600,8 @@ describe('v8debugapi', function() {
590600 function ( done ) {
591601 var bp = {
592602 id : 'coffee-id-1729' ,
593- location : { path : './ test/ fixtures/coffee/transpile. coffee',
594- line : 3 } ,
603+ location : { path : path . join ( '.' , ' test' , ' fixtures' , ' coffee',
604+ 'transpile.coffee' ) , line : 3 } ,
595605 condition : 'if n == 3 then true else false'
596606 } ;
597607 var tt = require ( './fixtures/coffee/transpile' ) ;
@@ -616,8 +626,8 @@ describe('v8debugapi', function() {
616626 function ( done ) {
617627 var bp = {
618628 id : 'coffee-id-1729' ,
619- location : { path : './ test/ fixtures/coffee/transpile. coffee',
620- line : 3 } ,
629+ location : { path : path . join ( '.' , ' test' , ' fixtures' , ' coffee',
630+ 'transpile.coffee' ) , line : 3 } ,
621631 condition : 'process=false'
622632 } ;
623633 api . set ( bp , function ( err ) {
@@ -631,7 +641,7 @@ describe('v8debugapi', function() {
631641 function ( done ) {
632642 var bp = {
633643 id : 'babel-id-1729' ,
634- location : { path : './ test/ fixtures/ es6/ transpile.es6',
644+ location : { path : path . join ( '.' , ' test' , ' fixtures' , ' es6' , ' transpile.es6') ,
635645 line : 3 } ,
636646 condition : 'i + j === 3'
637647 } ;
@@ -657,8 +667,8 @@ describe('v8debugapi', function() {
657667 function ( done ) {
658668 var bp = {
659669 id : 'coffee-id-1729' ,
660- location : { path : './ test/ fixtures/coffee/transpile. coffee',
661- line : 3 } ,
670+ location : { path : path . join ( '.' , ' test' , ' fixtures' , ' coffee',
671+ 'transpile.coffee' ) , line : 3 } ,
662672 expressions : [ 'if n == 3 then Math.PI * n else n' ]
663673 } ;
664674 var tt = require ( './fixtures/coffee/transpile' ) ;
@@ -686,7 +696,8 @@ describe('v8debugapi', function() {
686696 function ( done ) {
687697 var bp = {
688698 id : 'coffee-id-1729' ,
689- location : { path : './test/fixtures/coffee/transpile.coffee' ,
699+ location : { path : path . join ( '.' , 'test' , 'fixtures' ,
700+ 'coffee' , 'transpile.coffee' ) ,
690701 line : 3 } ,
691702 expressions : [ ':)' , 'n n, n' , 'process=this' , '((x) -> x x) n' , 'return' ]
692703 } ;
0 commit comments