def test_dead_processes(self): ctrlq = queue.Queue() # Not enough FINISH elements in the queue, processes start already dead # Also queue elements are reversed ctrlq.put((CONTROL_ELEMENT.GLOBAL_FINISHED, None)) ctrlq.put((CONTROL_ELEMENT.LOCAL_FINISHED, None)) process_queues( [DummyProcess(ctrlq, starts_dead=True) for i in range(3)], ctrlq, {}, {}, {}, lambda *args: self.queue.put(args[2]), Section(""), None, self.log_printer) with self.assertRaises(queue.Empty): self.queue.get(timeout=0) # Not enough FINISH elements in the queue, processes start already dead ctrlq.put((CONTROL_ELEMENT.LOCAL_FINISHED, None)) ctrlq.put((CONTROL_ELEMENT.GLOBAL_FINISHED, None)) process_queues( [DummyProcess(ctrlq, starts_dead=True) for i in range(3)], ctrlq, {}, {}, {}, lambda *args: self.queue.put(args[2]), Section(""), None, self.log_printer) with self.assertRaises(queue.Empty): self.queue.get(timeout=0)
def test_dead_processes(self): ctrlq = queue.Queue() # Not enough FINISH elements in the queue, processes start already dead # Also queue elements are reversed ctrlq.put((CONTROL_ELEMENT.GLOBAL_FINISHED, None)) ctrlq.put((CONTROL_ELEMENT.LOCAL_FINISHED, None)) process_queues( [DummyProcess(ctrlq, starts_dead=True) for i in range(3)], ctrlq, {}, {}, {}, lambda *args: self.queue.put(args[2]), Section(''), None, self.log_printer, self.console_printer) with self.assertRaises(queue.Empty): self.queue.get(timeout=0) # Not enough FINISH elements in the queue, processes start already dead ctrlq.put((CONTROL_ELEMENT.LOCAL_FINISHED, None)) ctrlq.put((CONTROL_ELEMENT.GLOBAL_FINISHED, None)) process_queues( [DummyProcess(ctrlq, starts_dead=True) for i in range(3)], ctrlq, {}, {}, {}, lambda *args: self.queue.put(args[2]), Section(''), None, self.log_printer, self.console_printer) with self.assertRaises(queue.Empty): self.queue.get(timeout=0)
def test_process_queues(self): ctrlq = queue.Queue() # Append custom controlling sequences. # Simulated process 1 ctrlq.put((CONTROL_ELEMENT.LOCAL, 1)) ctrlq.put((CONTROL_ELEMENT.LOCAL_FINISHED, None)) ctrlq.put((CONTROL_ELEMENT.GLOBAL, 1)) # Simulated process 2 ctrlq.put((CONTROL_ELEMENT.LOCAL, 2)) # Simulated process 1 ctrlq.put((CONTROL_ELEMENT.GLOBAL_FINISHED, None)) # Simulated process 2 ctrlq.put((CONTROL_ELEMENT.LOCAL_FINISHED, None)) ctrlq.put((CONTROL_ELEMENT.GLOBAL, 1)) ctrlq.put((CONTROL_ELEMENT.GLOBAL_FINISHED, None)) process_queues( [DummyProcess(control_queue=ctrlq) for i in range(3)], ctrlq, {1: ["The first result."], 2: ["The second result.", HiddenResult("t", "c")]}, {1: ["The one and only global result."]}, None, lambda *args: self.queue.put((args[2], args[3])), Section(""), self.log_printer, {}) self.assertEqual(self.queue.get(timeout=0), (["The first result."], None)) self.assertEqual(self.queue.get(timeout=0), (["The second result."], None)) self.assertEqual(self.queue.get(timeout=0), (["The one and only global result."], None)) self.assertEqual(self.queue.get(timeout=0), (["The one and only global result."], None)) # No valid FINISH element in the queue ctrlq.put((CONTROL_ELEMENT.GLOBAL_FINISHED, None)) process_queues( [DummyProcess(control_queue=ctrlq) for i in range(3)], ctrlq, {1: "The first result.", 2: "The second result."}, {1: "The one and only global result."}, None, lambda *args: self.queue.put((args[2], args[3])), Section(""), self.log_printer, {}) with self.assertRaises(queue.Empty): self.queue.get(timeout=0)
def test_process_queues(self): ctrlq = queue.Queue() # Append custom controlling sequences. # Simulated process 1 ctrlq.put((CONTROL_ELEMENT.LOCAL, 1)) ctrlq.put((CONTROL_ELEMENT.LOCAL_FINISHED, None)) ctrlq.put((CONTROL_ELEMENT.GLOBAL, 1)) # Simulated process 2 ctrlq.put((CONTROL_ELEMENT.LOCAL, 2)) # Simulated process 1 ctrlq.put((CONTROL_ELEMENT.GLOBAL_FINISHED, None)) # Simulated process 2 ctrlq.put((CONTROL_ELEMENT.LOCAL_FINISHED, None)) ctrlq.put((CONTROL_ELEMENT.GLOBAL, 1)) ctrlq.put((CONTROL_ELEMENT.GLOBAL_FINISHED, None)) first_local = Result.from_values('o', 'The first result.', file='f') second_local = Result.from_values('ABear', 'The second result.', file='f', line=1) third_local = Result.from_values('ABear', 'The second result.', file='f', line=4) fourth_local = Result.from_values('ABear', 'Another result.', file='f', line=7) first_global = Result('o', 'The one and only global result.') section = Section('') section.append(Setting('min_severity', 'normal')) process_queues( [DummyProcess(control_queue=ctrlq) for i in range(3)], ctrlq, { 1: [ first_local, second_local, third_local, # The following are to be ignored Result('o', 'm', severity=RESULT_SEVERITY.INFO), Result.from_values('ABear', 'u', 'f', 2, 1), Result.from_values('ABear', 'u', 'f', 3, 1) ], 2: [ fourth_local, # The following are to be ignored HiddenResult('t', 'c'), Result.from_values('ABear', 'u', 'f', 5, 1), Result.from_values('ABear', 'u', 'f', 6, 1) ] }, {1: [first_global]}, { 'f': [ 'first line # stop ignoring, invalid ignore range\n', 'second line # ignore all\n', 'third line\n', "fourth line # gnore shouldn't trigger without i!\n", '# Start ignoring ABear, BBear and CBear\n', '# Stop ignoring\n', 'seventh' ] }, lambda *args: self.queue.put(args[2]), section, None, self.log_printer, self.console_printer) self.assertEqual(self.queue.get(timeout=0), ([second_local, third_local])) self.assertEqual(self.queue.get(timeout=0), ([fourth_local])) self.assertEqual(self.queue.get(timeout=0), ([first_global])) self.assertEqual(self.queue.get(timeout=0), ([first_global]))
def test_process_queues(self): ctrlq = queue.Queue() # Append custom controlling sequences. # Simulated process 1 ctrlq.put((CONTROL_ELEMENT.LOCAL, 1)) ctrlq.put((CONTROL_ELEMENT.LOCAL_FINISHED, None)) ctrlq.put((CONTROL_ELEMENT.GLOBAL, 1)) # Simulated process 2 ctrlq.put((CONTROL_ELEMENT.LOCAL, 2)) # Simulated process 1 ctrlq.put((CONTROL_ELEMENT.GLOBAL_FINISHED, None)) # Simulated process 2 ctrlq.put((CONTROL_ELEMENT.LOCAL_FINISHED, None)) ctrlq.put((CONTROL_ELEMENT.GLOBAL, 1)) ctrlq.put((CONTROL_ELEMENT.GLOBAL_FINISHED, None)) first_local = Result.from_values("o", "The first result.", file="f") second_local = Result.from_values("ABear", "The second result.", file="f", line=1) third_local = Result.from_values("ABear", "The second result.", file="f", line=4) fourth_local = Result.from_values("ABear", "Another result.", file="f", line=7) first_global = Result("o", "The one and only global result.") section = Section("") section.append(Setting('min_severity', "normal")) process_queues( [DummyProcess(control_queue=ctrlq) for i in range(3)], ctrlq, {1: [first_local, second_local, third_local, # The following are to be ignored Result('o', 'm', severity=RESULT_SEVERITY.INFO), Result.from_values("ABear", "u", "f", 2, 1), Result.from_values("ABear", "u", "f", 3, 1)], 2: [fourth_local, # The following are to be ignored HiddenResult("t", "c"), Result.from_values("ABear", "u", "f", 5, 1), Result.from_values("ABear", "u", "f", 6, 1)]}, {1: [first_global]}, {"f": ["first line # stop ignoring, invalid ignore range\n", "second line # ignore all\n", "third line\n", "fourth line # gnore shouldn't trigger without i!\n", "# Start ignoring ABear, BBear and CBear\n", "# Stop ignoring\n", "seventh"]}, lambda *args: self.queue.put(args[2]), section, None, self.log_printer) self.assertEqual(self.queue.get(timeout=0), ([first_local, second_local, third_local])) self.assertEqual(self.queue.get(timeout=0), ([fourth_local])) self.assertEqual(self.queue.get(timeout=0), ([first_global])) self.assertEqual(self.queue.get(timeout=0), ([first_global]))
def test_process_queues(self): ctrlq = queue.Queue() # Append custom controlling sequences. # Simulated process 1 ctrlq.put((CONTROL_ELEMENT.LOCAL, 1)) ctrlq.put((CONTROL_ELEMENT.LOCAL_FINISHED, None)) ctrlq.put((CONTROL_ELEMENT.GLOBAL, 1)) # Simulated process 2 ctrlq.put((CONTROL_ELEMENT.LOCAL, 2)) # Simulated process 1 ctrlq.put((CONTROL_ELEMENT.GLOBAL_FINISHED, None)) # Simulated process 2 ctrlq.put((CONTROL_ELEMENT.LOCAL_FINISHED, None)) ctrlq.put((CONTROL_ELEMENT.GLOBAL, 1)) ctrlq.put((CONTROL_ELEMENT.GLOBAL_FINISHED, None)) first_local = Result.from_values("o", "The first result.", file="f") second_local = Result.from_values("ABear", "The second result.", file="f", line=1) third_local = Result.from_values("ABear", "The second result.", file="f", line=4) fourth_local = Result.from_values("ABear", "Another result.", file="f", line=7) first_global = Result("o", "The one and only global result.") section = Section("") section.append(Setting('min_severity', "normal")) process_queues( [DummyProcess(control_queue=ctrlq) for i in range(3)], ctrlq, { 1: [ first_local, second_local, third_local, # The following are to be ignored Result('o', 'm', severity=RESULT_SEVERITY.INFO), Result.from_values("ABear", "u", file="f", line=2), Result.from_values("ABear", "u", file="f", line=3) ], 2: [ fourth_local, # The following are to be ignored HiddenResult("t", "c"), Result.from_values("ABear", "u", file="f", line=5), Result.from_values("ABear", "u", file="f", line=6) ] }, {1: [first_global]}, { "f": [ "first line # stop ignoring, invalid ignore range\n", "second line # ignore all\n", "third line\n", "fourth line\n", "# Start ignoring ABear, BBear and CBear\n", "# Stop ignoring\n", "seventh" ] }, lambda *args: self.queue.put(args[2]), section, self.log_printer) self.assertEqual(self.queue.get(timeout=0), ([first_local, second_local, third_local])) self.assertEqual(self.queue.get(timeout=0), ([fourth_local])) self.assertEqual(self.queue.get(timeout=0), ([first_global])) self.assertEqual(self.queue.get(timeout=0), ([first_global]))
def test_process_queues(self): ctrlq = queue.Queue() # Append custom controlling sequences. # Simulated process 1 ctrlq.put((CONTROL_ELEMENT.LOCAL, 1)) ctrlq.put((CONTROL_ELEMENT.LOCAL_FINISHED, None)) ctrlq.put((CONTROL_ELEMENT.GLOBAL, 1)) # Simulated process 2 ctrlq.put((CONTROL_ELEMENT.LOCAL, 2)) # Simulated process 1 ctrlq.put((CONTROL_ELEMENT.GLOBAL_FINISHED, None)) # Simulated process 2 ctrlq.put((CONTROL_ELEMENT.LOCAL_FINISHED, None)) ctrlq.put((CONTROL_ELEMENT.GLOBAL, 1)) ctrlq.put((CONTROL_ELEMENT.GLOBAL_FINISHED, None)) first_local = Result.from_values('o', 'The first result.', file='f') second_local = Result.from_values('ABear', 'The second result.', file='f', line=1) third_local = Result.from_values('ABear', 'The second result.', file='f', line=4) fourth_local = Result.from_values('ABear', 'Another result.', file='f', line=7) first_global = Result('o', 'The one and only global result.') section = Section('') section.append(Setting('min_severity', 'normal')) process_queues( [DummyProcess(control_queue=ctrlq) for i in range(3)], ctrlq, {1: [first_local, second_local, third_local, # The following are to be ignored Result('o', 'm', severity=RESULT_SEVERITY.INFO), Result.from_values('ABear', 'u', 'f', 2, 1), Result.from_values('ABear', 'u', 'f', 3, 1)], 2: [fourth_local, # The following are to be ignored HiddenResult('t', 'c'), Result.from_values('ABear', 'u', 'f', 5, 1), Result.from_values('ABear', 'u', 'f', 6, 1)]}, {1: [first_global]}, {'f': self.file_dict[self.factory_test_file]}, lambda *args: self.queue.put(args[2]), section, None, self.log_printer, self.console_printer) self.assertEqual(self.queue.get(timeout=0), ([second_local, third_local])) self.assertEqual(self.queue.get(timeout=0), ([fourth_local])) self.assertEqual(self.queue.get(timeout=0), ([first_global])) self.assertEqual(self.queue.get(timeout=0), ([first_global]))