-
Notifications
You must be signed in to change notification settings - Fork 323
/
Copy pathtest-api-manual-plugin.js
46 lines (42 loc) · 1.3 KB
/
test-api-manual-plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const CiPlugin = require('../../plugins/ci_plugin')
const {
TEST_STATUS,
finishAllTraceSpans,
getTestSuitePath
} = require('../../plugins/util/test')
const { storage } = require('../../../../datadog-core')
class TestApiManualPlugin extends CiPlugin {
static get id () {
return 'test-api-manual'
}
constructor (...args) {
super(...args)
this.sourceRoot = process.cwd()
this.addSub('dd-trace:ci:manual:test:start', ({ testName, testSuite }) => {
const store = storage.getStore()
const testSuiteRelative = getTestSuitePath(testSuite, this.sourceRoot)
const testSpan = this.startTestSpan(testName, testSuiteRelative)
this.enter(testSpan, store)
})
this.addSub('dd-trace:ci:manual:test:finish', ({ status, error }) => {
const store = storage.getStore()
const testSpan = store && store.span
if (testSpan) {
testSpan.setTag(TEST_STATUS, status)
if (error) {
testSpan.setTag('error', error)
}
testSpan.finish()
finishAllTraceSpans(testSpan)
}
})
this.addSub('dd-trace:ci:manual:test:addTags', (tags) => {
const store = storage.getStore()
const testSpan = store && store.span
if (testSpan) {
testSpan.addTags(tags)
}
})
}
}
module.exports = TestApiManualPlugin