mixed.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * @author Toru Nagashima
  3. * @copyright 2016 Toru Nagashima. All rights reserved.
  4. * See LICENSE file in root directory for full license.
  5. */
  6. 'use strict'
  7. // ------------------------------------------------------------------------------
  8. // Requirements
  9. // ------------------------------------------------------------------------------
  10. const assert = require('assert').strict
  11. const { result, removeResult, runAll } = require('./lib/util')
  12. // ------------------------------------------------------------------------------
  13. // Test
  14. // ------------------------------------------------------------------------------
  15. describe('[mixed] npm-run-all', () => {
  16. before(() => process.chdir('test-workspace'))
  17. after(() => process.chdir('..'))
  18. beforeEach(removeResult)
  19. it('should run a mix of sequential and parallel tasks (has the default group):', async () => {
  20. await runAll([
  21. 'test-task:append a',
  22. '-p', 'test-task:append b', 'test-task:append c',
  23. '-s', 'test-task:append d', 'test-task:append e',
  24. ])
  25. assert(
  26. result() === 'aabcbcddee' ||
  27. result() === 'aabccbddee' ||
  28. result() === 'aacbbcddee' ||
  29. result() === 'aacbcbddee'
  30. )
  31. })
  32. it("should run a mix of sequential and parallel tasks (doesn't have the default group):", async () => {
  33. await runAll([
  34. '-p', 'test-task:append b', 'test-task:append c',
  35. '-s', 'test-task:append d', 'test-task:append e',
  36. ])
  37. assert(
  38. result() === 'bcbcddee' ||
  39. result() === 'bccbddee' ||
  40. result() === 'cbbcddee' ||
  41. result() === 'cbcbddee'
  42. )
  43. })
  44. it('should not throw errors for --race and --max-parallel options if --parallel exists:', () =>
  45. runAll([
  46. 'test-task:append a',
  47. '-p', 'test-task:append b', 'test-task:append c',
  48. '-s', 'test-task:append d', 'test-task:append e',
  49. '-r',
  50. ]))
  51. })