From 09a2593b1d009a8ee0e4c3481579b0f28d8abf94 Mon Sep 17 00:00:00 2001 From: Darshit Shah Date: Wed, 25 Dec 2013 01:52:50 +0530 Subject: [PATCH 2/6] Improve error handling when wget executable isn't available --- testenv/ChangeLog | 7 +++++++ testenv/WgetTest.py | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/testenv/ChangeLog b/testenv/ChangeLog index 879685a..6b58f18 100644 --- a/testenv/ChangeLog +++ b/testenv/ChangeLog @@ -1,3 +1,10 @@ +2013-12-25 Darshit Shah + + * WgetTest.py (CommonMehtods.exec_wget): Catch and handle exception if the + Wget executable is not found at src/wget + (HTTPTest.call_test): In case of error during execution, remove all existing + servers before quitting + 2013-12-15 Darshit Shah * WgetTest.py (HTTPTest.HTTP_setup): Rename to Server_setup so it can be diff --git a/testenv/WgetTest.py b/testenv/WgetTest.py index a856cd8..09c1d85 100644 --- a/testenv/WgetTest.py +++ b/testenv/WgetTest.py @@ -40,7 +40,11 @@ class CommonMethods: cmd_line = self.get_cmd_line (options, urls, domain_list) params = shlex.split (cmd_line) print (params) - retcode = call (params) + try: + retcode = call (params) + except FileNotFoundError as filenotfound: + raise TestFailed ( + "The Wget Executable does not exist at the expected path") return retcode def get_cmd_line (self, options, urls, domain_list): @@ -270,7 +274,11 @@ class HTTPTest (CommonMethods): raise TestFailed ("Test Option " + test_func + " unknown.") getattr (self, test_func) (test_params[test_func]) - self.act_retcode = self.exec_wget (self.options, self.urls, self.domain_list) + try: + self.act_retcode = self.exec_wget (self.options, self.urls, self.domain_list) + except TestFailed as tf: + self.stop_HTTP_Server () + raise TestFailed (tf.__str__ ()) self.stop_HTTP_Server () def post_hook_call (self, post_hook): -- 1.8.5.2