diff options
author | Daniel Moody <dmoody256@gmail.com> | 2017-12-10 00:15:52 (GMT) |
---|---|---|
committer | Daniel Moody <dmoody256@gmail.com> | 2017-12-10 00:15:52 (GMT) |
commit | 32259ec9338ff814857dbada1d7322213a532bc3 (patch) | |
tree | 6b24ae602074038fe4a1d6ffc91ec76ec0ed5c8f | |
parent | 459da59f3d32349f95d5cad95d390463ff157312 (diff) | |
download | SCons-32259ec9338ff814857dbada1d7322213a532bc3.zip SCons-32259ec9338ff814857dbada1d7322213a532bc3.tar.gz SCons-32259ec9338ff814857dbada1d7322213a532bc3.tar.bz2 |
moved logic to function so less duplicate code
-rw-r--r-- | QMTest/TestSCons.py | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 807d0bc..f0d25cb 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -784,6 +784,16 @@ class TestSCons(TestCommon): print("Could not determine JAVA_HOME: %s is not a directory" % home) self.fail_test() + def java_mac_check(self, where_java_bin, java_bin_name): + # on Mac there is a place holder java installed to start the java install process + # so we need to check the output in this case, more info here: + # http://anas.pk/2015/09/02/solution-no-java-runtime-present-mac-yosemite/ + sp = subprocess.Popen([where_java_bin, "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = sp.communicate() + sp.wait() + if("No Java runtime" in str(stderr)): + self.skip_test("Could not find Java " + java_bin_name + ", skipping test(s).\n") + def java_where_jar(self, version=None): ENV = self.java_ENV(version) if self.detect_tool('jar', ENV=ENV): @@ -792,15 +802,9 @@ class TestSCons(TestCommon): where_jar = self.where_is('jar', ENV['PATH']) if not where_jar: self.skip_test("Could not find Java jar, skipping test(s).\n") - elif sys.platform == "darwin": - # on Mac there is a place holder java installed to start the java install process - # so we need to check the output in this case, more info here: - # http://anas.pk/2015/09/02/solution-no-java-runtime-present-mac-yosemite/ - sp = subprocess.Popen([where_jar, "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = sp.communicate() - sp.wait() - if("No Java runtime" in str(stderr)): - self.skip_test("Could not find Java jar, skipping test(s).\n") + elif sys.platform == "darwin": + self.java_mac_check(where_jar, 'jar') + return where_jar def java_where_java(self, version=None): @@ -813,14 +817,8 @@ class TestSCons(TestCommon): if not where_java: self.skip_test("Could not find Java java, skipping test(s).\n") elif sys.platform == "darwin": - # on Mac there is a place holder java installed to start the java install process - # so we need to check the output in this case, more info here: - # http://anas.pk/2015/09/02/solution-no-java-runtime-present-mac-yosemite/ - sp = subprocess.Popen([where_java, "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = sp.communicate() - sp.wait() - if("No Java runtime" in str(stderr)): - self.skip_test("Could not find Java java, skipping test(s).\n") + self.java_mac_check(where_java, 'java') + return where_java def java_where_javac(self, version=None): @@ -835,14 +833,8 @@ class TestSCons(TestCommon): if not where_javac: self.skip_test("Could not find Java javac, skipping test(s).\n") elif sys.platform == "darwin": - # on Mac there is a place holder java installed to start the java install process - # so we need to check the output in this case, more info here: - # http://anas.pk/2015/09/02/solution-no-java-runtime-present-mac-yosemite/ - sp = subprocess.Popen([where_javac, "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = sp.communicate() - sp.wait() - if("No Java runtime" in str(stderr)): - self.skip_test("Could not find Java javac, skipping test(s).\n") + self.java_mac_check(where_javac, 'javac') + self.run(program = where_javac, arguments = '-version', stderr=None, |