pr_26637.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. diff --git a/services/clsi/app/js/LocalCommandRunner.js b/services/clsi/app/js/LocalCommandRunner.js
  2. index ce274733585..aa62825443c 100644
  3. --- a/services/clsi/app/js/LocalCommandRunner.js
  4. +++ b/services/clsi/app/js/LocalCommandRunner.js
  5. @@ -54,6 +54,7 @@ module.exports = CommandRunner = {
  6. cwd: directory,
  7. env,
  8. stdio: ['pipe', 'pipe', 'ignore'],
  9. + detached: true,
  10. })
  11. let stdout = ''
  12. diff --git a/services/clsi/test/acceptance/js/StopCompile.js b/services/clsi/test/acceptance/js/StopCompile.js
  13. new file mode 100644
  14. index 00000000000..103a70f37d7
  15. --- /dev/null
  16. +++ b/services/clsi/test/acceptance/js/StopCompile.js
  17. @@ -0,0 +1,47 @@
  18. +const Client = require('./helpers/Client')
  19. +const ClsiApp = require('./helpers/ClsiApp')
  20. +const { expect } = require('chai')
  21. +
  22. +describe('Stop compile', function () {
  23. + before(function (done) {
  24. + this.request = {
  25. + options: {
  26. + timeout: 100,
  27. + }, // seconds
  28. + resources: [
  29. + {
  30. + path: 'main.tex',
  31. + content: `\
  32. +\\documentclass{article}
  33. +\\begin{document}
  34. +\\def\\x{Hello!\\par\\x}
  35. +\\x
  36. +\\end{document}\
  37. +`,
  38. + },
  39. + ],
  40. + }
  41. + this.project_id = Client.randomId()
  42. + ClsiApp.ensureRunning(() => {
  43. + // start the compile in the background
  44. + Client.compile(this.project_id, this.request, (error, res, body) => {
  45. + this.compileResult = { error, res, body }
  46. + })
  47. + // wait for 1 second before stopping the compile
  48. + setTimeout(() => {
  49. + Client.stopCompile(this.project_id, (error, res, body) => {
  50. + this.stopResult = { error, res, body }
  51. + setTimeout(done, 1000) // allow time for the compile request to terminate
  52. + })
  53. + }, 1000)
  54. + })
  55. + })
  56. +
  57. + it('should force a compile response with an error status', function () {
  58. + expect(this.stopResult.error).to.be.null
  59. + expect(this.stopResult.res.statusCode).to.equal(204)
  60. + expect(this.compileResult.res.statusCode).to.equal(200)
  61. + expect(this.compileResult.body.compile.status).to.equal('terminated')
  62. + expect(this.compileResult.body.compile.error).to.equal('terminated')
  63. + })
  64. +})
  65. diff --git a/services/clsi/test/acceptance/js/helpers/Client.js b/services/clsi/test/acceptance/js/helpers/Client.js
  66. index a0bdce734f3..49bf7390c6f 100644
  67. --- a/services/clsi/test/acceptance/js/helpers/Client.js
  68. +++ b/services/clsi/test/acceptance/js/helpers/Client.js
  69. @@ -42,6 +42,16 @@ module.exports = Client = {
  70. )
  71. },
  72. + stopCompile(projectId, callback) {
  73. + if (callback == null) {
  74. + callback = function () {}
  75. + }
  76. + return request.post(
  77. + { url: `${this.host}/project/${projectId}/compile/stop` },
  78. + callback
  79. + )
  80. + },
  81. +
  82. clearCache(projectId, callback) {
  83. if (callback == null) {
  84. callback = function () {}