added test for recursive file inclusion detection
authorKai Dietrich <mail@cleeus.de>
Sat, 30 Oct 2010 17:57:56 +0000 (19:57 +0200)
committerKai Dietrich <mail@cleeus.de>
Sat, 30 Oct 2010 17:57:56 +0000 (19:57 +0200)
tests/test_file_loop [new file with mode: 0644]
tests/test_wiki2beamer.py

diff --git a/tests/test_file_loop b/tests/test_file_loop
new file mode 100644 (file)
index 0000000..610c718
--- /dev/null
@@ -0,0 +1,2 @@
+test_file_loop content
+>>>test_file_loop<<<
index 70081a54fae12e5870740377701f3900b6d4f3d3..7b204a580bd45ec42d638a66b10b8628bbd05749 100755 (executable)
@@ -18,6 +18,7 @@ import sys
 import unittest
 import re
 import random
+import threading
 
 sys.path.append('../code')
 from wiki2beamer import *
@@ -313,6 +314,19 @@ class TestFileInclusion(unittest.TestCase):
         expected = ['content from test_file3', '<[nowiki]', '>>>test_file<<<', '[nowiki]>']
         out = include_file_recursive([line])
         self.assertEqual(expected, out)
+    
+    def test_include_file_recursive_detects_loop(self):
+        line = ">>>test_file_loop<<<"
+        expected = ["test_file_loop content"]
+        
+        include_worker = threading.Thread(target=include_file_recursive,args=([line],))
+
+        include_worker.start()
+
+        #wait 1 second, if the thread is still working after 1s we certainly have an infinite loop
+        include_worker.join(1.0)
+        self.assertFalse( include_worker.is_alive() )
+        
 
 class TestSelectedFramesMode(unittest.TestCase):
     def setUp(self):