aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/worker.py25
-rw-r--r--worker/specs2
2 files changed, 19 insertions, 8 deletions
diff --git a/tests/worker.py b/tests/worker.py
index 25ff5aab..cf121f38 100644
--- a/tests/worker.py
+++ b/tests/worker.py
@@ -14,6 +14,9 @@ class WorkerTests(unittest.TestCase):
def prompt(self, n):
return ('#%i#\r\n' % n)
+ def interrupted(self, n):
+ return ('#%i# INTERRUPTED\r\n' % n)
+
def setUp(self):
self.worker = pexpect.spawn('python ../worker/worker.py')
# worker should always be very fast to span
@@ -48,24 +51,32 @@ class WorkerTests(unittest.TestCase):
self.sendlines(['exit'])
self.__finishes_ok__()
- def test_ctrlc_on_cmd_prompt_quits(self):
+ def test_ctrlc_when_running(self):
+ self.sendlines(['exec', 'sleep 1; exec echo lol'])
self.sig(SIGINT)
- self.expect(pexpect.EOF)
- self.__finishes_ok__()
+ self.expect(self.interrupted(0)+self.prompt(1))
+ self.test_exit()
+
+ def test_ctrlc_on_cmd_prompt(self):
+ self.sig(SIGINT)
+ self.expect(self.interrupted(0)+self.prompt(1))
+ self.test_exit()
- def test_ctrlc_when_entering_command_quits(self):
+ def test_ctrlc_when_entering_command(self):
# "Mon clavier se blo" -- French reference
self.send('glo')
self.sig(SIGINT)
- self.expect(pexpect.EOF)
+ self.expect(self.interrupted(0)+self.prompt(1))
+ self.test_exit()
def test_ctrlc_on_readparms_drops(self):
self.sendlines(['exec'])
self.sig(SIGINT)
- self.expect(self.prompt(0))
+ self.expect(self.interrupted(0)+self.prompt(1))
self.sendlines(['glob'])
self.sig(SIGINT)
- self.expect(self.prompt(0))
+ self.expect(self.interrupted(1)+self.prompt(2))
+ self.test_exit()
def test_basic_noop(self):
self.sendlines(['noop'])
diff --git a/worker/specs b/worker/specs
index 76baa272..0d1b7dd1 100644
--- a/worker/specs
+++ b/worker/specs
@@ -38,7 +38,7 @@ number.
/- by Python to display exceptions;
/- to print "ALIVE" when SIGUSR1 is received or after a "ping" request;
/- to print "UNKNOWN COMMAND" when a command is unknown;
-/- to print "INTERRUPTED" when a command is interrupted with SIGINT.
+/- to print "INTERRUPTED #X#" when a command is interrupted with SIGINT.
[statement(easy to prove wrong, hard to prove right)]
Requests