Skip to content

Commit ded8006

Browse files
committed
Relativize mocha json file paths
1 parent 24f1d07 commit ded8006

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

plugins/resources/matrix.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const mocha = require("mocha");
22
const inherits = require("util").inherits;
33
const Spec = mocha.reporters.Spec;
4+
const path = require('path');
45

56
/**
67
* This file adapted from mocha's stats-collector
@@ -105,7 +106,7 @@ function Matrix(runner, options) {
105106
return {
106107
title: info.title,
107108
fullTitle: info.fullTitle(),
108-
file: info.file,
109+
file: path.relative(options.reporterOptions.cwd, info.file),
109110
currentRetry: info.currentRetry(),
110111
err: cleanCycles(err)
111112
};

plugins/resources/nomiclabs.utils.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ function collectTestMatrixData(args, env, api){
175175
mochaConfig.reporter = api.matrixReporterPath;
176176
mochaConfig.reporterOptions = {
177177
collectTestMatrixData: api.collectTestMatrixData.bind(api),
178-
saveMochaJsonOutput: api.saveMochaJsonOutput.bind(api)
178+
saveMochaJsonOutput: api.saveMochaJsonOutput.bind(api),
179+
cwd: api.cwd
179180
}
180181
env.config.mocha = mochaConfig;
181182
}

plugins/resources/truffle.utils.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ function collectTestMatrixData(config, api){
241241
config.mocha.reporter = api.matrixReporterPath;
242242
config.mocha.reporterOptions = {
243243
collectTestMatrixData: api.collectTestMatrixData.bind(api),
244-
saveMochaJsonOutput: api.saveMochaJsonOutput.bind(api)
244+
saveMochaJsonOutput: api.saveMochaJsonOutput.bind(api),
245+
cwd: api.cwd
245246
}
246247
}
247248
}

test/integration/projects/matrix/expectedMochaOutput.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,42 @@
1010
{
1111
"title": "sends to A",
1212
"fullTitle": "Contract: Matrix A and B sends to A",
13-
"file": "/Users/cgewecke/code/sc-forks/solidity-coverage/sc_temp/test/matrix_a_b.js",
13+
"file": "test/matrix_a_b.js",
1414
"currentRetry": 0,
1515
"err": {}
1616
},
1717
{
1818
"title": "sends to A",
1919
"fullTitle": "Contract: Matrix A and B sends to A",
20-
"file": "/Users/cgewecke/code/sc-forks/solidity-coverage/sc_temp/test/matrix_a_b.js",
20+
"file": "test/matrix_a_b.js",
2121
"currentRetry": 0,
2222
"err": {}
2323
},
2424
{
2525
"title": "calls B",
2626
"fullTitle": "Contract: Matrix A and B calls B",
27-
"file": "/Users/cgewecke/code/sc-forks/solidity-coverage/sc_temp/test/matrix_a_b.js",
27+
"file": "test/matrix_a_b.js",
2828
"currentRetry": 0,
2929
"err": {}
3030
},
3131
{
3232
"title": "sends to B",
3333
"fullTitle": "Contract: Matrix A and B sends to B",
34-
"file": "/Users/cgewecke/code/sc-forks/solidity-coverage/sc_temp/test/matrix_a_b.js",
34+
"file": "test/matrix_a_b.js",
3535
"currentRetry": 0,
3636
"err": {}
3737
},
3838
{
3939
"title": "sends",
4040
"fullTitle": "Contract: MatrixA sends",
41-
"file": "/Users/cgewecke/code/sc-forks/solidity-coverage/sc_temp/test/matrix_a.js",
41+
"file": "test/matrix_a.js",
4242
"currentRetry": 0,
4343
"err": {}
4444
},
4545
{
4646
"title": "calls",
4747
"fullTitle": "Contract: MatrixA calls",
48-
"file": "/Users/cgewecke/code/sc-forks/solidity-coverage/sc_temp/test/matrix_a.js",
48+
"file": "test/matrix_a.js",
4949
"currentRetry": 0,
5050
"err": {}
5151
}
@@ -55,42 +55,42 @@
5555
{
5656
"title": "sends to A",
5757
"fullTitle": "Contract: Matrix A and B sends to A",
58-
"file": "/Users/cgewecke/code/sc-forks/solidity-coverage/sc_temp/test/matrix_a_b.js",
58+
"file": "test/matrix_a_b.js",
5959
"currentRetry": 0,
6060
"err": {}
6161
},
6262
{
6363
"title": "sends to A",
6464
"fullTitle": "Contract: Matrix A and B sends to A",
65-
"file": "/Users/cgewecke/code/sc-forks/solidity-coverage/sc_temp/test/matrix_a_b.js",
65+
"file": "test/matrix_a_b.js",
6666
"currentRetry": 0,
6767
"err": {}
6868
},
6969
{
7070
"title": "calls B",
7171
"fullTitle": "Contract: Matrix A and B calls B",
72-
"file": "/Users/cgewecke/code/sc-forks/solidity-coverage/sc_temp/test/matrix_a_b.js",
72+
"file": "test/matrix_a_b.js",
7373
"currentRetry": 0,
7474
"err": {}
7575
},
7676
{
7777
"title": "sends to B",
7878
"fullTitle": "Contract: Matrix A and B sends to B",
79-
"file": "/Users/cgewecke/code/sc-forks/solidity-coverage/sc_temp/test/matrix_a_b.js",
79+
"file": "test/matrix_a_b.js",
8080
"currentRetry": 0,
8181
"err": {}
8282
},
8383
{
8484
"title": "sends",
8585
"fullTitle": "Contract: MatrixA sends",
86-
"file": "/Users/cgewecke/code/sc-forks/solidity-coverage/sc_temp/test/matrix_a.js",
86+
"file": "test/matrix_a.js",
8787
"currentRetry": 0,
8888
"err": {}
8989
},
9090
{
9191
"title": "calls",
9292
"fullTitle": "Contract: MatrixA calls",
93-
"file": "/Users/cgewecke/code/sc-forks/solidity-coverage/sc_temp/test/matrix_a.js",
93+
"file": "test/matrix_a.js",
9494
"currentRetry": 0,
9595
"err": {}
9696
}

0 commit comments

Comments
 (0)