|
|
@ -8,7 +8,7 @@ const mock = require('../../util/integration.truffle'); |
|
|
|
const plugin = require('../../../dist/truffle.plugin'); |
|
|
|
const plugin = require('../../../dist/truffle.plugin'); |
|
|
|
|
|
|
|
|
|
|
|
// =======================
|
|
|
|
// =======================
|
|
|
|
// Standard Use-case Tests
|
|
|
|
// CLI Options / Flags
|
|
|
|
// =======================
|
|
|
|
// =======================
|
|
|
|
|
|
|
|
|
|
|
|
describe('Truffle Plugin: command line options', function() { |
|
|
|
describe('Truffle Plugin: command line options', function() { |
|
|
@ -28,8 +28,11 @@ describe('Truffle Plugin: command line options', function() { |
|
|
|
it('truffle run coverage --file test/<fileName>', async function() { |
|
|
|
it('truffle run coverage --file test/<fileName>', async function() { |
|
|
|
verify.cleanInitialState(); |
|
|
|
verify.cleanInitialState(); |
|
|
|
|
|
|
|
|
|
|
|
const testPath = path.join(truffleConfig.working_directory, 'test/specific_a.js'); |
|
|
|
truffleConfig.file = path.join( |
|
|
|
truffleConfig.file = testPath; |
|
|
|
truffleConfig.working_directory, |
|
|
|
|
|
|
|
'test/specific_a.js' |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
mock.installFullProject('test-files'); |
|
|
|
mock.installFullProject('test-files'); |
|
|
|
await plugin(truffleConfig); |
|
|
|
await plugin(truffleConfig); |
|
|
|
|
|
|
|
|
|
|
@ -54,8 +57,11 @@ describe('Truffle Plugin: command line options', function() { |
|
|
|
it('truffle run coverage --file test/<glob*>', async function() { |
|
|
|
it('truffle run coverage --file test/<glob*>', async function() { |
|
|
|
verify.cleanInitialState(); |
|
|
|
verify.cleanInitialState(); |
|
|
|
|
|
|
|
|
|
|
|
const testPath = path.join(truffleConfig.working_directory, 'test/globby*'); |
|
|
|
truffleConfig.file = path.join( |
|
|
|
truffleConfig.file = testPath; |
|
|
|
truffleConfig.working_directory, |
|
|
|
|
|
|
|
'test/globby*' |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
mock.installFullProject('test-files'); |
|
|
|
mock.installFullProject('test-files'); |
|
|
|
await plugin(truffleConfig); |
|
|
|
await plugin(truffleConfig); |
|
|
|
|
|
|
|
|
|
|
@ -80,8 +86,11 @@ describe('Truffle Plugin: command line options', function() { |
|
|
|
it('truffle run coverage --file test/gl{o,b}*.js', async function() { |
|
|
|
it('truffle run coverage --file test/gl{o,b}*.js', async function() { |
|
|
|
verify.cleanInitialState(); |
|
|
|
verify.cleanInitialState(); |
|
|
|
|
|
|
|
|
|
|
|
const testPath = path.join(truffleConfig.working_directory, 'test/gl{o,b}*.js'); |
|
|
|
truffleConfig.file = path.join( |
|
|
|
truffleConfig.file = testPath; |
|
|
|
truffleConfig.working_directory, |
|
|
|
|
|
|
|
'test/gl{o,b}*.js' |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
mock.installFullProject('test-files'); |
|
|
|
mock.installFullProject('test-files'); |
|
|
|
await plugin(truffleConfig); |
|
|
|
await plugin(truffleConfig); |
|
|
|
|
|
|
|
|
|
|
@ -110,17 +119,20 @@ describe('Truffle Plugin: command line options', function() { |
|
|
|
silent: process.env.SILENT ? true : false, |
|
|
|
silent: process.env.SILENT ? true : false, |
|
|
|
istanbulReporter: ['json-summary', 'text'] |
|
|
|
istanbulReporter: ['json-summary', 'text'] |
|
|
|
}; |
|
|
|
}; |
|
|
|
fs.writeFileSync('.solcover.js', `module.exports=${JSON.stringify(solcoverConfig)}`); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This relative path has to be ./ prefixed
|
|
|
|
// Write solcoverjs to parent dir of sc_temp (where the test project is installed)
|
|
|
|
// (because it's path.joined to truffle's working_directory)
|
|
|
|
fs.writeFileSync( |
|
|
|
|
|
|
|
'.solcover.js', |
|
|
|
|
|
|
|
`module.exports=${JSON.stringify(solcoverConfig)}` |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This relative path has to be ./ prefixed (it's path.joined to truffle's working_directory)
|
|
|
|
truffleConfig.solcoverjs = './../.solcover.js'; |
|
|
|
truffleConfig.solcoverjs = './../.solcover.js'; |
|
|
|
|
|
|
|
|
|
|
|
mock.install('Simple', 'simple.js'); |
|
|
|
mock.install('Simple', 'simple.js'); |
|
|
|
await plugin(truffleConfig); |
|
|
|
await plugin(truffleConfig); |
|
|
|
|
|
|
|
|
|
|
|
// The relative solcoverjs uses the json-summary reporter which
|
|
|
|
// The relative solcoverjs uses the json-summary reporter
|
|
|
|
// this assertion requires
|
|
|
|
|
|
|
|
const expected = [{ |
|
|
|
const expected = [{ |
|
|
|
file: mock.pathToContract(truffleConfig, 'Simple.sol'), |
|
|
|
file: mock.pathToContract(truffleConfig, 'Simple.sol'), |
|
|
|
pct: 100 |
|
|
|
pct: 100 |
|
|
@ -132,68 +144,72 @@ describe('Truffle Plugin: command line options', function() { |
|
|
|
|
|
|
|
|
|
|
|
it('truffle run coverage --help', async function(){ |
|
|
|
it('truffle run coverage --help', async function(){ |
|
|
|
verify.cleanInitialState(); |
|
|
|
verify.cleanInitialState(); |
|
|
|
truffleConfig.help = "true"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
truffleConfig.help = "true"; |
|
|
|
truffleConfig.logger = mock.testLogger; |
|
|
|
truffleConfig.logger = mock.testLogger; |
|
|
|
|
|
|
|
|
|
|
|
mock.install('Simple', 'simple.js', solcoverConfig); |
|
|
|
mock.install('Simple', 'simple.js', solcoverConfig); |
|
|
|
await plugin(truffleConfig); |
|
|
|
await plugin(truffleConfig); |
|
|
|
|
|
|
|
|
|
|
|
assert( |
|
|
|
assert( |
|
|
|
mock.loggerOutput.val.includes('Usage'), |
|
|
|
mock.loggerOutput.val.includes('Usage'), |
|
|
|
`Should output help with Usage instruction (output --> ${mock.loggerOutput.val}` |
|
|
|
`Should output help with Usage instruction : ${mock.loggerOutput.val}` |
|
|
|
); |
|
|
|
); |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
it('truffle run coverage --version', async function(){ |
|
|
|
it('truffle run coverage --version', async function(){ |
|
|
|
verify.cleanInitialState(); |
|
|
|
verify.cleanInitialState(); |
|
|
|
truffleConfig.version = "true"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
truffleConfig.version = "true"; |
|
|
|
truffleConfig.logger = mock.testLogger; |
|
|
|
truffleConfig.logger = mock.testLogger; |
|
|
|
|
|
|
|
|
|
|
|
mock.install('Simple', 'simple.js', solcoverConfig); |
|
|
|
mock.install('Simple', 'simple.js', solcoverConfig); |
|
|
|
await plugin(truffleConfig); |
|
|
|
await plugin(truffleConfig); |
|
|
|
|
|
|
|
|
|
|
|
assert( |
|
|
|
assert( |
|
|
|
mock.loggerOutput.val.includes('truffle'), |
|
|
|
mock.loggerOutput.val.includes('truffle'), |
|
|
|
`Should output truffle version (output --> ${mock.loggerOutput.val}` |
|
|
|
`Should output truffle version: ${mock.loggerOutput.val}` |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
assert( |
|
|
|
assert( |
|
|
|
mock.loggerOutput.val.includes('ganache-core'), |
|
|
|
mock.loggerOutput.val.includes('ganache-core'), |
|
|
|
`Should output ganache-core version (output --> ${mock.loggerOutput.val}` |
|
|
|
`Should output ganache-core version: ${mock.loggerOutput.val}` |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
assert( |
|
|
|
assert( |
|
|
|
mock.loggerOutput.val.includes('solidity-coverage'), |
|
|
|
mock.loggerOutput.val.includes('solidity-coverage'), |
|
|
|
`Should output solidity-coverage version (output --> ${mock.loggerOutput.val}` |
|
|
|
`Should output solidity-coverage version: ${mock.loggerOutput.val}` |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
it('truffle run coverage --useGlobalTruffle', async function(){ |
|
|
|
it('truffle run coverage --useGlobalTruffle', async function(){ |
|
|
|
verify.cleanInitialState(); |
|
|
|
verify.cleanInitialState(); |
|
|
|
truffleConfig.useGlobalTruffle = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
truffleConfig.useGlobalTruffle = true; |
|
|
|
truffleConfig.logger = mock.testLogger; |
|
|
|
truffleConfig.logger = mock.testLogger; |
|
|
|
|
|
|
|
|
|
|
|
mock.install('Simple', 'simple.js', solcoverConfig); |
|
|
|
mock.install('Simple', 'simple.js', solcoverConfig); |
|
|
|
await plugin(truffleConfig); |
|
|
|
await plugin(truffleConfig); |
|
|
|
|
|
|
|
|
|
|
|
assert( |
|
|
|
assert( |
|
|
|
mock.loggerOutput.val.includes('global node_modules'), |
|
|
|
mock.loggerOutput.val.includes('global node_modules'), |
|
|
|
`Should notify it's using global truffle (output --> ${mock.loggerOutput.val}` |
|
|
|
`Should notify it's using global truffle: ${mock.loggerOutput.val}` |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('truffle run coverage --usePluginTruffle', async function(){ |
|
|
|
it('truffle run coverage --usePluginTruffle', async function(){ |
|
|
|
verify.cleanInitialState(); |
|
|
|
verify.cleanInitialState(); |
|
|
|
truffleConfig.usePluginTruffle = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
truffleConfig.usePluginTruffle = true; |
|
|
|
truffleConfig.logger = mock.testLogger; |
|
|
|
truffleConfig.logger = mock.testLogger; |
|
|
|
|
|
|
|
|
|
|
|
mock.install('Simple', 'simple.js', solcoverConfig); |
|
|
|
mock.install('Simple', 'simple.js', solcoverConfig); |
|
|
|
await plugin(truffleConfig); |
|
|
|
await plugin(truffleConfig); |
|
|
|
|
|
|
|
|
|
|
|
assert( |
|
|
|
assert( |
|
|
|
mock.loggerOutput.val.includes('fallback Truffle library module'), |
|
|
|
mock.loggerOutput.val.includes('fallback Truffle library module'), |
|
|
|
`Should notify it's using plugin truffle lib copy (output --> ${mock.loggerOutput.val}` |
|
|
|
`Should notify it's using plugin truffle lib copy: ${mock.loggerOutput.val}` |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|