workshopper / workshopper-exercise

An exercise runner component for the Workshopper framework
Other
57 stars 35 forks source link

v1.1.0 empty process.argv on execution #13

Open talon opened 9 years ago

talon commented 9 years ago

While working on updating the levelmeup nodeschool to the latest workshopper I ran into an error where workshopper-exercise v1.1.0 doesn't pass arguments when you run the solution. v0.2.3 works though.

the error with v1.1.0

levelmeup run solutions/solution.js
ALL YOUR undefined ARE BELONG TO undefined.

The code that is run.

 var exercise      = require('workshopper-exercise')()
  , filecheck     = require('workshopper-exercise/filecheck')
  , execute       = require('workshopper-exercise/execute')
  , comparestdout = require('workshopper-exercise/comparestdout')

// checks that the submission file actually exists
exercise = filecheck(exercise)

// execute the solution and submission in parallel with spawn()
exercise = execute(exercise)

// compare stdout of solution and submission
exercise = comparestdout(exercise)

exercise.addSetup(function (mode, callback) {

  // array for substitution in: 'ALL YOUR X ARE BELONG TO Y'
  const inputs = [
      [ 'BASE', 'US' ]
    , [ 'LANDS AND POSESSIONS', 'VIKINGS OF WESTERN NORWAY' ]
    , [ 'INDEPENDENCE', 'KING HENRY VIII' ]
    , [ 'INTERNET COMMUNICATIONS', 'THE NSA' ]
    , [ 'TICKS', 'LIBUV' ]
  ]

  var i = Math.floor(Math.random() * inputs.length)
  this.submissionArgs = this.solutionArgs = inputs[i]

  process.nextTick(callback)
})

module.exports = exercise