You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
934 B

4 years ago
  1. var WebSocket = require('..').Client,
  2. deflate = require('permessage-deflate'),
  3. pace = require('pace');
  4. var host = 'ws://localhost:9001',
  5. agent = encodeURIComponent('node-' + process.version),
  6. cases = 0,
  7. options = {extensions: [deflate]};
  8. var socket = new WebSocket(host + '/getCaseCount'),
  9. url, progress;
  10. socket.onmessage = function(event) {
  11. console.log('Total cases to run: ' + event.data);
  12. cases = parseInt(event.data);
  13. progress = pace(cases);
  14. };
  15. var runCase = function(n) {
  16. if (n > cases) {
  17. url = host + '/updateReports?agent=' + agent;
  18. socket = new WebSocket(url);
  19. socket.onclose = process.exit;
  20. return;
  21. }
  22. url = host + '/runCase?case=' + n + '&agent=' + agent;
  23. socket = new WebSocket(url, [], options);
  24. socket.pipe(socket);
  25. socket.on('close', function() {
  26. progress.op();
  27. runCase(n + 1);
  28. });
  29. };
  30. socket.onclose = function() {
  31. runCase(1);
  32. };