From: Dylan Baker <[email protected]>

This is cleaner and more in keeping with the style of piglit.

Signed-off-by: Dylan Baker <[email protected]>
---
 framework/core.py       | 7 +++----
 unittests/core_tests.py | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/framework/core.py b/framework/core.py
index aa21df5..a75e598 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -28,7 +28,6 @@ from __future__ import (
 import errno
 import os
 import subprocess
-import sys
 
 from six.moves import configparser
 
@@ -121,9 +120,9 @@ def checkDir(dirname, failifexists):
         os.stat(dirname)
     except OSError as e:
         if e.errno not in [errno.ENOENT, errno.ENOTDIR] and failifexists:
-            print("%(dirname)s exists already.\nUse --overwrite if "
-                  "you want to overwrite it.\n" % locals(), file=sys.stderr)
-            exit(1)
+            raise exceptions.PiglitFatalError(
+                "%(dirname)s exists already.\nUse --overwrite if "
+                "you want to overwrite it.\n" % locals())
 
     try:
         if not os.path.exists(dirname):
diff --git a/unittests/core_tests.py b/unittests/core_tests.py
index 4b05721..043440b 100644
--- a/unittests/core_tests.py
+++ b/unittests/core_tests.py
@@ -278,7 +278,7 @@ class TestPiglitConfig(object):
 
 
 @utils.capture_stderr
[email protected](SystemExit)
[email protected](exceptions.PiglitFatalError)
 def test_check_dir_exists_fail():
     """core.check_dir: if the directory exists and failifexsits is True fail"""
     with mock.patch('framework.core.os.stat', mock.Mock(side_effect=OSError)):
-- 
2.8.2

_______________________________________________
Piglit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to