tests for custom optimize option

pull/5370/head
aniket-engg 4 years ago
parent 8905c78b7e
commit 69a23378b6
  1. 21
      libs/remix-tests/src/compiler.ts
  2. 4
      libs/remix-tests/src/run.ts
  3. 13
      libs/remix-tests/tests/testRunner.cli.spec.ts

@ -126,15 +126,20 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts:
async.waterfall([
function loadCompiler(next) {
compiler = new RemixCompiler()
const {currentCompilerUrl, evmVersion, optimize, runs} = compilerConfig
evmVersion ? compiler.set('evmVersion', evmVersion) :
optimize ? compiler.set('optimize', optimize) :
runs ? compiler.set('runs', runs) : ''
if(currentCompilerUrl) {
compiler.loadRemoteVersion(currentCompilerUrl)
compiler.event.register('compilerLoaded', this, function (version) {
if(compilerConfig) {
const {currentCompilerUrl, evmVersion, optimize, runs} = compilerConfig
evmVersion ? compiler.set('evmVersion', evmVersion) : null
optimize ? compiler.set('optimize', optimize) : null
runs ? compiler.set('runs', runs) : null
if(currentCompilerUrl) {
compiler.loadRemoteVersion(currentCompilerUrl)
compiler.event.register('compilerLoaded', this, function (version) {
next()
});
} else {
compiler.onInternalCompilerLoaded()
next()
});
}
} else {
compiler.onInternalCompilerLoaded()
next()

@ -99,8 +99,8 @@ commander
}
if (commander.optimize) {
compilerConfig.optimize = commander.optimize
log.info(`Optimization is ${compilerConfig.optimize ? 'enabled' : 'disabled'}`)
compilerConfig.optimize = commander.optimize
log.info(`Optimization is ${compilerConfig.optimize ? 'enabled' : 'disabled'}`)
}
const web3 = new Web3()

@ -77,5 +77,18 @@ Commands:
// macth fail test details
expect(res.stdout.toString().trim()).toMatch(/error: okFailTest fails/)
})
test('remix-tests running a test file by enabling optimization', () => {
const res = spawnSync(executablePath, ['--optimize', 'true', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
// match initial lines
expect(res.stdout.toString().trim().includes('Optimization is enabled')).toBeTruthy()
expect(res.stdout.toString().trim()).toMatch(/:: Running remix-tests - Unit testing for solidity ::/)
expect(res.stdout.toString().trim()).toMatch(/creation of library remix_tests.sol:Assert pending.../)
// match test result
expect(res.stdout.toString().trim()).toMatch(/Ok pass test/)
expect(res.stdout.toString().trim()).toMatch(/Ok fail test/)
// macth fail test details
expect(res.stdout.toString().trim()).toMatch(/error: okFailTest fails/)
})
})
})
Loading…
Cancel
Save