path runTestFiles for injecting import statements, update readme

pull/7/head
0mkar 7 years ago
parent 0412ea4aa6
commit 3dacdccfe9
  1. 2
      remix-tests/README.md
  2. 2
      remix-tests/examples/simple_storage2_test.sol
  3. 11
      remix-tests/src/compiler.js

@ -101,7 +101,7 @@ params:
* `{ type: 'testPass', value: '<name of testing function>', time: <time taken>, context: '<TestName>'}`
* `{ type: 'testFailure', value: '<name of testing function>', time: <time taken>, context: '<TestName>', errMsg: '<message in the Assert>' }`
`resultCallback(object)`
`resultCallback(err, object)`
* `passingNum` - number of passing tests
* `failureNum` - number of failing tests
* `timePassed` - time it took for all the tests to run (in seconds)

@ -1,5 +1,5 @@
pragma solidity ^0.4.7;
import "remix_test.sol";
import "remix_tests.sol";
import "./simple_storage.sol";
contract MyTest2 {

@ -18,7 +18,6 @@ function compileFileOrFiles (filename, isDirectory, cb) {
'tests.sol': { content: require('../sol/tests.sol.js') },
'remix_tests.sol': { content: require('../sol/tests.sol.js') }
}
// signale.debug(sources)
// TODO: for now assumes filepath dir contains all tests, later all this
// should be replaced with remix's & browser solidity compiler code
@ -63,9 +62,17 @@ function compileFileOrFiles (filename, isDirectory, cb) {
function compileContractSources (sources, importFileCb, cb) {
let compiler, filepath
if (!sources['remix_tests.sol']) {
// Iterate over sources keys. Inject test libraries. Inject test library import statements.
if (!('remix_tests.sol' in sources) && !('tests.sol' in sources)) {
sources['remix_tests.sol'] = { content: require('../sol/tests.sol.js') }
}
const s = /^(import)\s['"](remix_tests.sol|tests.sol)['"];/gm
for (let file in sources) {
const c = sources[file].content
if (file.indexOf('_test.sol') > 0 && c && c.regexIndexOf(s) < 0) {
sources[file].content = c.replace(/(pragma solidity \^\d+\.\d+\.\d+;)/, '$1\nimport \'remix_tests.sol\';')
}
}
async.waterfall([
function loadCompiler (next) {

Loading…
Cancel
Save