Skip to content

Commit 2af43a3

Browse files
authored
Fix html report function highlighting / add netlify deploy preview (sc-forks#518)
1 parent f1fb8a0 commit 2af43a3

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

lib/instrumenter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Instrumenter {
6060
this._initializeCoverageFields(contract);
6161

6262
// First, we run over the original contract to get the source mapping.
63-
let ast = SolidityParser.parse(contract.source, {range: true});
63+
let ast = SolidityParser.parse(contract.source, {loc: true, range: true});
6464
parse[ast.type](contract, ast);
6565
const retValue = JSON.parse(JSON.stringify(contract)); // Possibly apotropaic.
6666

@@ -69,7 +69,7 @@ class Instrumenter {
6969
contract.instrumented = preprocess(contract.source);
7070

7171
// Walk the AST, recording injection points
72-
ast = SolidityParser.parse(contract.instrumented, {range: true});
72+
ast = SolidityParser.parse(contract.instrumented, {loc: true, range: true});
7373

7474
const root = ast.children.filter(node => this._isRootNode(node));
7575

lib/registrar.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,12 @@ class Registrar {
125125
start,
126126
start + endlineDelta
127127
);
128-
const endline = startline + (functionDefinition.match(/\n/g) || []).length;
129-
const endcol = functionDefinition.length - functionDefinition.lastIndexOf('\n');
130128

131129
contract.fnId += 1;
132130
contract.fnMap[contract.fnId] = {
133131
name: expression.isConstructor ? 'constructor' : expression.name,
134132
line: startline,
135-
loc: {
136-
start: { line: startline, column: startcol },
137-
end: { line: endline, column: endcol },
138-
},
133+
loc: expression.loc
139134
};
140135

141136
this._createInjectionPoint(

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"nyc": "SILENT=true nyc --exclude '**/sc_temp/**' --exclude '**/test/**'",
1414
"test": "SILENT=true node --max-old-space-size=4096 ./node_modules/.bin/nyc --exclude '**/sc_temp/**' --exclude '**/test/**/' -- mocha test/units/* --timeout 100000 --no-warnings --exit",
1515
"test:ci": "SILENT=true node --max-old-space-size=4096 ./node_modules/.bin/nyc --reporter=lcov --exclude '**/sc_temp/**' --exclude '**/test/**/' -- mocha test/units/* --timeout 100000 --no-warnings --exit",
16-
"test:debug": "node --max-old-space-size=4096 ./node_modules/.bin/mocha test/units/* --timeout 100000 --no-warnings --exit"
16+
"test:debug": "node --max-old-space-size=4096 ./node_modules/.bin/mocha test/units/* --timeout 100000 --no-warnings --exit",
17+
"netlify": "./scripts/run-netlify.sh"
1718
},
1819
"homepage": "https://github.com/sc-forks/solidity-coverage",
1920
"repository": {

scripts/run-netlify.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
#
3+
# E2E: runs sc-forks/hegic/contracts-v1 coverage and publishes html report in netlify
4+
# for CI deployment preview. This is the netlify "build" step.
5+
#
6+
7+
set -o errexit
8+
9+
# Clone target
10+
git clone https://github.com/sc-forks/contracts-v1.git
11+
cd contracts-v1
12+
13+
# Install solidity-coverage @ current commit
14+
yarn
15+
yarn add --dev https://github.com/sc-forks/solidity-coverage.git#$COMMIT_REF
16+
17+
cat package.json
18+
19+
npm run coverage

0 commit comments

Comments
 (0)