@@ -14,7 +14,7 @@ const telemetryAbort = ['abort', 'reason:incompatible_runtime', 'abort.runtime',
1414const telemetryForced = [ 'complete' , 'injection_forced:true' ]
1515const telemetryGood = [ 'complete' , 'injection_forced:false' ]
1616
17- const { engines } = require ( '../package.json' )
17+ const { engines, nodeMaxMajor : MAX_NODE_MAJOR } = require ( '../package.json' )
1818const {
1919 runAndCheckWithTelemetry : testFile ,
2020 useEnv,
@@ -122,15 +122,15 @@ function testRuntimeVersionChecks (arg, filename) {
122122 it ( 'should be able to use the engines field' , ( ) => {
123123 const engines = require ( `${ sandboxCwd ( ) } /node_modules/dd-trace/package.json` ) . engines . node
124124
125- assert . match ( engines , / ^ > = \d + < \d + $ / )
125+ assert . match ( engines , / ^ > = \d + $ / )
126126 } )
127127
128- context ( 'when node version is too recent ' , ( ) => {
128+ context ( 'when node version is too old ' , ( ) => {
129129 useEnv ( { NODE_OPTIONS } )
130130
131131 before ( ( ) => {
132132 const pkg = JSON . parse ( pkgStr )
133- pkg . engines . node = `>=${ NODE_MAJOR - 1 } < ${ NODE_MAJOR } `
133+ pkg . engines . node = `>=${ NODE_MAJOR + 1 } `
134134 fs . writeFileSync ( pkgPath , JSON . stringify ( pkg ) )
135135 } )
136136
@@ -151,14 +151,14 @@ function testRuntimeVersionChecks (arg, filename) {
151151 it ( 'should not initialize the tracer' , ( ) =>
152152 doTest ( `Aborting application instrumentation due to incompatible_runtime.
153153Found incompatible runtime Node.js ${ process . versions . node } , Supported runtimes: Node.js \
154- >=${ NODE_MAJOR - 1 } <${ NODE_MAJOR } .
154+ >=${ NODE_MAJOR + 1 } <${ MAX_NODE_MAJOR } .
155155false
156156` , telemetryAbort ) )
157157
158158 it ( 'should initialize the tracer, if DD_INJECT_FORCE' , ( ) =>
159159 doTestForced ( `Aborting application instrumentation due to incompatible_runtime.
160160Found incompatible runtime Node.js ${ process . versions . node } , Supported runtimes: Node.js \
161- >=${ NODE_MAJOR - 1 } <${ NODE_MAJOR } .
161+ >=${ NODE_MAJOR + 1 } <${ MAX_NODE_MAJOR } .
162162DD_INJECT_FORCE enabled, allowing unsupported runtimes and continuing.
163163Application instrumentation bootstrapping complete
164164true
@@ -167,12 +167,12 @@ true
167167 } )
168168 } )
169169
170- context ( 'when node version is too old ' , ( ) => {
170+ context ( 'when node version is too recent ' , ( ) => {
171171 useEnv ( { NODE_OPTIONS } )
172172
173173 before ( ( ) => {
174174 const pkg = JSON . parse ( pkgStr )
175- pkg . engines . node = `>= ${ NODE_MAJOR + 1 } < ${ NODE_MAJOR + 2 } `
175+ pkg . nodeMaxMajor = NODE_MAJOR
176176 fs . writeFileSync ( pkgPath , JSON . stringify ( pkg ) )
177177 } )
178178
@@ -193,14 +193,14 @@ true
193193 it ( 'should not initialize the tracer' , ( ) =>
194194 doTest ( `Aborting application instrumentation due to incompatible_runtime.
195195Found incompatible runtime Node.js ${ process . versions . node } , Supported runtimes: Node.js \
196- >= ${ NODE_MAJOR + 1 } <${ NODE_MAJOR + 2 } .
196+ ${ engines . node } <${ NODE_MAJOR } .
197197false
198198` , telemetryAbort ) )
199199
200200 it ( 'should initialize the tracer, if DD_INJECT_FORCE' , ( ) =>
201201 doTestForced ( `Aborting application instrumentation due to incompatible_runtime.
202202Found incompatible runtime Node.js ${ process . versions . node } , Supported runtimes: Node.js \
203- >= ${ NODE_MAJOR + 1 } <${ NODE_MAJOR + 2 } .
203+ ${ engines . node } <${ NODE_MAJOR } .
204204DD_INJECT_FORCE enabled, allowing unsupported runtimes and continuing.
205205Application instrumentation bootstrapping complete
206206true
215215
216216 before ( ( ) => {
217217 const pkg = JSON . parse ( pkgStr )
218- pkg . engines . node = '>=0 <1000'
218+ pkg . engines . node = '>=0'
219+ pkg . nodeMaxMajor = 1000
219220 fs . writeFileSync ( pkgPath , JSON . stringify ( pkg ) )
220221 } )
221222
0 commit comments