always append remix-tests:sol reference

pull/5370/head
yann300 6 years ago committed by GitHub
parent e159b42ffa
commit 0b405ed75f
  1. 3
      remix-tests/src/compiler.js

@ -47,8 +47,9 @@ function compileFileOrFiles (filename, isDirectory, opts, cb) {
if (foundpath.split('.').pop() === 'sol') { if (foundpath.split('.').pop() === 'sol') {
let c = fs.readFileSync(foundpath).toString() let c = fs.readFileSync(foundpath).toString()
const s = /^(import)\s['"](remix_tests.sol|tests.sol)['"];/gm const s = /^(import)\s['"](remix_tests.sol|tests.sol)['"];/gm
let includeTestLibs = '\nimport \'remix_tests.sol\';\n'
if (foundpath.indexOf('_test.sol') > 0 && c.regexIndexOf(s) < 0) { if (foundpath.indexOf('_test.sol') > 0 && c.regexIndexOf(s) < 0) {
c = c.replace(/(pragma solidity \^?\d+\.\d+\.\d+;)/, '$1\nimport \'remix_tests.sol\';') c = includeTestLibs.concat(c)
} }
sources[foundpath] = { content: c } sources[foundpath] = { content: c }
} }

Loading…
Cancel
Save