diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/dev-utils/src/env.ts | 19 | ||||
-rw-r--r-- | packages/sol-cov/src/collect_coverage_entries.ts (renamed from packages/sol-cov/src/instrument_solidity.ts) | 1 | ||||
-rw-r--r-- | packages/sol-cov/src/coverage_manager.ts | 2 |
3 files changed, 20 insertions, 2 deletions
diff --git a/packages/dev-utils/src/env.ts b/packages/dev-utils/src/env.ts new file mode 100644 index 000000000..7e46a5f89 --- /dev/null +++ b/packages/dev-utils/src/env.ts @@ -0,0 +1,19 @@ +import * as _ from 'lodash'; +import * as process from 'process'; + +export const env = { + parseBoolean(key: string): boolean { + let isTrue: boolean; + const envVarvalue = process.env[key]; + if (process.env.SOLIDITY_COVERAGE === 'true') { + isTrue = true; + } else if (process.env.SOLIDITY_COVERAGE === 'false' || _.isUndefined(process.env.SOLIDITY_COVERAGE)) { + isTrue = false; + } else { + throw new Error( + `Failed to parse ENV variable ${key} as boolean. Please make sure it's either true or false. Defaults to false`, + ); + } + return isTrue; + }, +}; diff --git a/packages/sol-cov/src/instrument_solidity.ts b/packages/sol-cov/src/collect_coverage_entries.ts index 163e3c7b9..d29fa2c37 100644 --- a/packages/sol-cov/src/instrument_solidity.ts +++ b/packages/sol-cov/src/collect_coverage_entries.ts @@ -11,7 +11,6 @@ import { getLocationByOffset } from './source_maps'; const coverageEntriesBySourceHash: { [sourceHash: string]: CoverageEntriesDescription } = {}; export const collectCoverageEntries = (contractSource: string, fileName: string) => { - const time = Date.now(); const sourceHash = ethUtil.sha3(contractSource).toString('hex'); if (_.isUndefined(coverageEntriesBySourceHash[sourceHash])) { const ast = SolidityParser.parse(contractSource); diff --git a/packages/sol-cov/src/coverage_manager.ts b/packages/sol-cov/src/coverage_manager.ts index 870dc2bdb..4ca6b0ec8 100644 --- a/packages/sol-cov/src/coverage_manager.ts +++ b/packages/sol-cov/src/coverage_manager.ts @@ -4,8 +4,8 @@ import * as _ from 'lodash'; import * as path from 'path'; import { collectContractsData } from './collect_contract_data'; +import { collectCoverageEntries } from './collect_coverage_entries'; import { constants } from './constants'; -import { collectCoverageEntries } from './instrument_solidity'; import { parseSourceMap } from './source_maps'; import { BranchCoverage, |