Skip to content

Commit 3a42089

Browse files
committedJul 17, 2015
Loading worksmith versions dynamically for stress testing
1 parent 62c381b commit 3a42089

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed
 

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"xregexp": "^2.0.0"
3131
},
3232
"devDependencies": {
33-
"mocha": "^2.2.5"
33+
"mocha": "^2.2.5",
34+
"require-version": "^1.0.0"
3435
}
3536
}

‎stress-test/stress-test.js

+22-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
1-
var worksmith = require('..')
21
var _ = require('lodash')
32
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'
75

86
var SAMPLE_SIZE = 100
97

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+
}
1928
}
2029

2130
function calculateAverageExecTime(workflow, next) {

0 commit comments

Comments
 (0)
Please sign in to comment.