|
1 |
| -var worksmith = require('..') |
2 | 1 | var _ = require('lodash')
|
3 | 2 | var async = require('async')
|
4 |
| -packageJson = require('../package.json') |
5 |
| - |
6 |
| -console.log('Stress tests for worksmith version ', packageJson.version) |
| 3 | +var requireVersion = require('require-version') |
| 4 | +var myModule = 'worksmith' |
7 | 5 |
|
8 | 6 | var SAMPLE_SIZE = 100
|
9 | 7 |
|
10 |
| -try { |
11 |
| - worksmith.use("lodash", worksmith.createAdapter(require('lodash'))) |
12 |
| - var workflow = worksmith("./stress-test/stress-workflows/workflow1.js") |
13 |
| - console.log('About to execute workflow1') |
14 |
| - calculateAverageExecTime(workflow, function(average) { |
15 |
| - console.log('The average execution time is: ', average, ' ms') |
16 |
| - }) |
17 |
| -} catch(e) { |
18 |
| - console.error('There was an error setting up a workflow: ', e) |
| 8 | +requireVersion.execute(myModule, 3, function(module, version, next) { |
| 9 | + console.log('Executing tests for ', module, ' v', version) |
| 10 | + runTests(require(myModule), next) |
| 11 | +}, function(err) { |
| 12 | + if (err) console.log('Error: ', err) |
| 13 | + console.log('END') |
| 14 | +}) |
| 15 | + |
| 16 | +function runTests(worksmith, next) { |
| 17 | + try { |
| 18 | + worksmith.use("lodash", worksmith.createAdapter(require('lodash'))) |
| 19 | + var workflow = worksmith("./stress-test/stress-workflows/workflow1.js") |
| 20 | + console.log('About to execute workflow1') |
| 21 | + calculateAverageExecTime(workflow, function(average) { |
| 22 | + console.log('The average execution time is: ', average, ' ms') |
| 23 | + next() |
| 24 | + }) |
| 25 | + } catch(e) { |
| 26 | + next(e) |
| 27 | + } |
19 | 28 | }
|
20 | 29 |
|
21 | 30 | function calculateAverageExecTime(workflow, next) {
|
|
0 commit comments