@@ -25,19 +25,33 @@ const execArgvs = [
2525 {
2626 execArgv : [ '--loader' , 'dd-trace/loader-hook.mjs' ] ,
2727 skip : semver . satisfies ( process . versions . node , '>=20.6' )
28+ } ,
29+ {
30+ execArgv : [ ] ,
31+ optional : false
2832 }
2933]
3034
31- execArgvs . forEach ( ( { execArgv, skip } ) => {
35+ execArgvs . forEach ( ( { execArgv, skip, optional = true } ) => {
3236 const describe = skip ? globalThis . describe . skip : globalThis . describe
3337
34- describe ( `startup ${ execArgv . join ( ' ' ) } ` , ( ) => {
38+ describe ( `startup ${ execArgv . join ( ' ' ) . concat ( `(optional: ${ optional } )` ) } ` , ( ) => {
3539 let agent
3640 let proc
3741 let cwd
3842 let startupTestFile
3943 let unsupportedTestFile
4044
45+ before ( ( ) => {
46+ if ( optional === false ) {
47+ process . env . OMIT = 'optional'
48+ }
49+ } )
50+
51+ after ( ( ) => {
52+ delete process . env . OMIT
53+ } )
54+
4155 useSandbox ( [ 'd3-format@3.1.0' ] )
4256
4357 before ( ( ) => {
@@ -74,38 +88,41 @@ execArgvs.forEach(({ execArgv, skip }) => {
7488 } )
7589 } )
7690
77- it ( 'saves tracer configuration on disk' , async ( ) => {
78- if ( process . platform !== 'linux' ) {
79- return
80- }
81-
82- proc = await spawnProc ( startupTestFile , {
83- cwd,
84- execArgv,
85- env : {
86- AGENT_PORT : agent . port
91+ // This feature requires libdatadog which is an optional dependency.
92+ if ( optional ) {
93+ it ( 'saves tracer configuration on disk' , async ( ) => {
94+ if ( process . platform !== 'linux' ) {
95+ return
8796 }
88- } )
8997
90- const containsDatadogMemfd = ( fds ) => {
91- for ( const fd of fds ) {
92- try {
93- const fdName = fs . readlinkSync ( `/proc/${ proc . pid } /fd/${ fd } ` )
94- if ( fdName . includes ( 'datadog-tracer-info-' ) ) {
95- return true
96- }
97- } catch { }
98+ proc = await spawnProc ( startupTestFile , {
99+ cwd,
100+ execArgv,
101+ env : {
102+ AGENT_PORT : agent . port
103+ }
104+ } )
105+
106+ const containsDatadogMemfd = ( fds ) => {
107+ for ( const fd of fds ) {
108+ try {
109+ const fdName = fs . readlinkSync ( `/proc/${ proc . pid } /fd/${ fd } ` )
110+ if ( fdName . includes ( 'datadog-tracer-info-' ) ) {
111+ return true
112+ }
113+ } catch { }
114+ }
115+ return false
98116 }
99- return false
100- }
101117
102- const fds = fs . readdirSync ( `/proc/${ proc . pid } /fd` )
118+ const fds = fs . readdirSync ( `/proc/${ proc . pid } /fd` )
103119
104- assert (
105- containsDatadogMemfd ( fds ) ,
106- `FDs ${ inspect ( fds ) } of PID ${ proc . pid } did not contain the datadog tracer configuration in memfd`
107- )
108- } )
120+ assert (
121+ containsDatadogMemfd ( fds ) ,
122+ `FDs ${ inspect ( fds ) } of PID ${ proc . pid } did not contain the datadog tracer configuration in memfd`
123+ )
124+ } )
125+ }
109126
110127 it ( 'works for options.url' , async ( ) => {
111128 proc = await spawnProc ( startupTestFile , {
0 commit comments