Fix html report function highlighting / add netlify deploy preview (#518)

pull/519/head
cgewecke 5 years ago committed by GitHub
parent f1fb8a0f49
commit 2af43a3423
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      lib/instrumenter.js
  2. 7
      lib/registrar.js
  3. 3
      package.json
  4. 19
      scripts/run-netlify.sh

@ -60,7 +60,7 @@ class Instrumenter {
this._initializeCoverageFields(contract); this._initializeCoverageFields(contract);
// First, we run over the original contract to get the source mapping. // First, we run over the original contract to get the source mapping.
let ast = SolidityParser.parse(contract.source, {range: true}); let ast = SolidityParser.parse(contract.source, {loc: true, range: true});
parse[ast.type](contract, ast); parse[ast.type](contract, ast);
const retValue = JSON.parse(JSON.stringify(contract)); // Possibly apotropaic. const retValue = JSON.parse(JSON.stringify(contract)); // Possibly apotropaic.
@ -69,7 +69,7 @@ class Instrumenter {
contract.instrumented = preprocess(contract.source); contract.instrumented = preprocess(contract.source);
// Walk the AST, recording injection points // Walk the AST, recording injection points
ast = SolidityParser.parse(contract.instrumented, {range: true}); ast = SolidityParser.parse(contract.instrumented, {loc: true, range: true});
const root = ast.children.filter(node => this._isRootNode(node)); const root = ast.children.filter(node => this._isRootNode(node));

@ -125,17 +125,12 @@ class Registrar {
start, start,
start + endlineDelta start + endlineDelta
); );
const endline = startline + (functionDefinition.match(/\n/g) || []).length;
const endcol = functionDefinition.length - functionDefinition.lastIndexOf('\n');
contract.fnId += 1; contract.fnId += 1;
contract.fnMap[contract.fnId] = { contract.fnMap[contract.fnId] = {
name: expression.isConstructor ? 'constructor' : expression.name, name: expression.isConstructor ? 'constructor' : expression.name,
line: startline, line: startline,
loc: { loc: expression.loc
start: { line: startline, column: startcol },
end: { line: endline, column: endcol },
},
}; };
this._createInjectionPoint( this._createInjectionPoint(

@ -13,7 +13,8 @@
"nyc": "SILENT=true nyc --exclude '**/sc_temp/**' --exclude '**/test/**'", "nyc": "SILENT=true nyc --exclude '**/sc_temp/**' --exclude '**/test/**'",
"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", "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",
"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", "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",
"test:debug": "node --max-old-space-size=4096 ./node_modules/.bin/mocha test/units/* --timeout 100000 --no-warnings --exit" "test:debug": "node --max-old-space-size=4096 ./node_modules/.bin/mocha test/units/* --timeout 100000 --no-warnings --exit",
"netlify": "./scripts/run-netlify.sh"
}, },
"homepage": "https://github.com/sc-forks/solidity-coverage", "homepage": "https://github.com/sc-forks/solidity-coverage",
"repository": { "repository": {

@ -0,0 +1,19 @@
#!/usr/bin/env bash
#
# E2E: runs sc-forks/hegic/contracts-v1 coverage and publishes html report in netlify
# for CI deployment preview. This is the netlify "build" step.
#
set -o errexit
# Clone target
git clone https://github.com/sc-forks/contracts-v1.git
cd contracts-v1
# Install solidity-coverage @ current commit
yarn
yarn add --dev https://github.com/sc-forks/solidity-coverage.git#$COMMIT_REF
cat package.json
npm run coverage
Loading…
Cancel
Save