Skip to content

Commit ac5e0ea

Browse files
committed
Adjust tests for Windows
1 parent 1950e10 commit ac5e0ea

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

packages/dd-trace/test/profiling/config.spec.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ describe('config', () => {
8787
expect(config.exporters[0]._url.toString()).to.equal(options.url)
8888
expect(config.exporters[1]).to.be.an.instanceof(FileExporter)
8989
expect(config.profilers).to.be.an('array')
90-
expect(config.profilers.length).to.equal(3)
90+
expect(config.profilers.length).to.equal(2 + samplingContextsAvailable)
9191
expect(config.profilers[0]).to.be.an.instanceOf(SpaceProfiler)
9292
expect(config.profilers[1]).to.be.an.instanceOf(WallProfiler)
9393
expect(config.profilers[1].codeHotspotsEnabled()).false
94-
expect(config.profilers[2]).to.be.an.instanceOf(EventsProfiler)
94+
if (samplingContextsAvailable) {
95+
expect(config.profilers[2]).to.be.an.instanceOf(EventsProfiler)
96+
}
9597
})
9698

9799
it('should filter out invalid profilers', () => {
@@ -147,10 +149,12 @@ describe('config', () => {
147149
const config = new Config(options)
148150

149151
expect(config.profilers).to.be.an('array')
150-
expect(config.profilers.length).to.equal(2)
152+
expect(config.profilers.length).to.equal(1 + samplingContextsAvailable)
151153
expect(config.profilers[0]).to.be.an.instanceOf(WallProfiler)
152154
expect(config.profilers[0].codeHotspotsEnabled()).to.equal(samplingContextsAvailable)
153-
expect(config.profilers[1]).to.be.an.instanceOf(EventsProfiler)
155+
if (samplingContextsAvailable) {
156+
expect(config.profilers[1]).to.be.an.instanceOf(EventsProfiler)
157+
}
154158
expect(config.v8ProfilerBugWorkaroundEnabled).false
155159
expect(config.cpuProfilingEnabled).to.equal(samplingContextsAvailable)
156160
})
@@ -184,9 +188,11 @@ describe('config', () => {
184188
const config = new Config(options)
185189

186190
expect(config.profilers).to.be.an('array')
187-
expect(config.profilers.length).to.equal(2)
191+
expect(config.profilers.length).to.equal(1 + samplingContextsAvailable)
188192
expect(config.profilers[0]).to.be.an.instanceOf(WallProfiler)
189-
expect(config.profilers[1]).to.be.an.instanceOf(EventsProfiler)
193+
if (samplingContextsAvailable) {
194+
expect(config.profilers[1]).to.be.an.instanceOf(EventsProfiler)
195+
}
190196
})
191197

192198
it('should prioritize options over env variables', () => {

packages/dd-trace/test/profiling/profiler.spec.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ const SpaceProfiler = require('../../src/profiling/profilers/space')
99
const WallProfiler = require('../../src/profiling/profilers/wall')
1010
const EventsProfiler = require('../../src/profiling/profilers/events')
1111

12+
const samplingContextsAvailable = process.platform !== 'win32'
13+
1214
describe('profiler', function () {
1315
let Profiler
1416
let profiler
@@ -143,7 +145,7 @@ describe('profiler', function () {
143145
['wall,space', WallProfiler, SpaceProfiler, EventsProfiler],
144146
[['space', 'wall'], SpaceProfiler, WallProfiler, EventsProfiler],
145147
[['wall', 'space'], WallProfiler, SpaceProfiler, EventsProfiler]
146-
]
148+
].map(profilers => profilers.filter(profiler => samplingContextsAvailable || profiler !== EventsProfiler))
147149

148150
for (const [profilers, ...expected] of checks) {
149151
await profiler._start({

0 commit comments

Comments
 (0)