瀏覽代碼

HUE-8630 [core] xxd_test SkipTest if xxd is not found.

jdesjean 7 年之前
父節點
當前提交
2b38919
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      apps/filebrowser/src/filebrowser/lib/xxd_test.py

+ 8 - 2
apps/filebrowser/src/filebrowser/lib/xxd_test.py

@@ -17,14 +17,15 @@
 
 import unittest
 import logging
-import StringIO
 import random
+import StringIO
+import subprocess
 
 import xxd
 
 from subprocess import Popen, PIPE
 
-logger = logging.getLogger(__name__)
+LOG = logging.getLogger(__name__)
 
 LENGTH = 1024*10 # 10KB
 
@@ -73,6 +74,11 @@ class XxdTest(unittest.TestCase):
     To be honest, this test was written after this was working.
     I tested using a temporary file and a side-by-side diff tool (vimdiff).
     """
+    try:
+      subprocess.check_output('type xxd', shell=True)
+    except subprocess.CalledProcessError as e:
+      LOG.warn('xxd not found')
+      raise SkipTest
     # /dev/random tends to hang on Linux, so we use python instead.
     # It's inefficient, but it's not terrible.
     random_text = "".join(chr(random.getrandbits(8)) for _ in range(LENGTH))