1+ /*1* KEEP THIS CODE AT THE TOP TO AVOID LINE NUMBER CHANGES */
2+ /*2*/ 'use strict' ;
3+ /*3*/ function foo ( n ) {
4+ /*4*/ var A = new Array ( 3 ) ; return n + 42 + A [ 0 ] ;
5+ /*5*/ }
6+ /**
7+ * Copyright 2015 Google Inc. All Rights Reserved.
8+ *
9+ * Licensed under the Apache License, Version 2.0 (the "License");
10+ * you may not use this file except in compliance with the License.
11+ * You may obtain a copy of the License at
12+ *
13+ * http://www.apache.org/licenses/LICENSE-2.0
14+ *
15+ * Unless required by applicable law or agreed to in writing, software
16+ * distributed under the License is distributed on an "AS IS" BASIS,
17+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+ * See the License for the specific language governing permissions and
19+ * limitations under the License.
20+ */
21+
22+ process . env . GCLOUD_DIAGNOSTICS_CONFIG = 'test/fixtures/test-config.js' ;
23+
24+ var assert = require ( 'assert' ) ;
25+ var logModule = require ( '@google/cloud-diagnostics-common' ) . logger ;
26+ var v8debugapi = require ( '../../lib/v8debugapi.js' ) ;
27+ var scanner = require ( '../../lib/scanner.js' ) ;
28+ var config = require ( '../../config.js' ) ;
29+ var api ;
30+
31+ var breakpointInFoo = {
32+ id : 'fake-id-123' ,
33+ location : { path : 'test-max-data-size.js' , line : 4 }
34+ } ;
35+
36+ describe ( 'maxDataSize' , function ( ) {
37+ before ( function ( done ) {
38+ if ( ! api ) {
39+ var logger = logModule . create ( config . logLevel ) ;
40+ scanner . scan ( true , config . workingDirectory , function ( err , fileStats , hash ) {
41+ assert ( ! err ) ;
42+ api = v8debugapi . create ( logger , config , fileStats ) ;
43+ done ( ) ;
44+ } ) ;
45+ } else {
46+ done ( ) ;
47+ }
48+ } ) ;
49+
50+ it ( 'should limit data reported' , function ( done ) {
51+ config . capture . maxDataSize = 5 ;
52+ // clone a clean breakpointInFoo
53+ var bp = { id : breakpointInFoo . id , location : breakpointInFoo . location } ;
54+ api . set ( bp , function ( err ) {
55+ assert . ifError ( err ) ;
56+ api . wait ( bp , function ( err ) {
57+ assert . ifError ( err ) ;
58+ assert ( bp . variableTable . some ( function ( v ) {
59+ return v . status . description . format === 'Max data size reached' ;
60+ } ) ) ;
61+ api . clear ( bp ) ;
62+ done ( ) ;
63+ } ) ;
64+ process . nextTick ( function ( ) { foo ( 2 ) ; } ) ;
65+ } ) ;
66+ } ) ;
67+
68+ it ( 'should be unlimited if 0' , function ( done ) {
69+ config . capture . maxDataSize = 0 ;
70+ // clone a clean breakpointInFoo
71+ var bp = { id : breakpointInFoo . id , location : breakpointInFoo . location } ;
72+ api . set ( bp , function ( err ) {
73+ assert . ifError ( err ) ;
74+ api . wait ( bp , function ( err ) {
75+ assert . ifError ( err ) ;
76+ assert ( bp . variableTable . reduce ( function ( acc , elem ) {
77+ return acc && elem . status . description . format !== 'Max data size reached' ;
78+ } ) , true ) ;
79+ api . clear ( bp ) ;
80+ done ( ) ;
81+ } ) ;
82+ process . nextTick ( function ( ) { foo ( 2 ) ; } ) ;
83+ } ) ;
84+ } ) ;
85+ } ) ;
0 commit comments