From: stevenknight Date: Sat, 13 Aug 2005 05:42:18 +0000 (+0000) Subject: Add a skip_test() method to the infrastructure and use it for test scripts that skip... X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f46cc47cc849cf533ab051dfb561caa3584892a2;p=scons.git Add a skip_test() method to the infrastructure and use it for test scripts that skip all or part of their tests based on tool availability or test platform. git-svn-id: http://scons.tigris.org/svn/scons/trunk@1325 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/etc/TestSCons.py b/etc/TestSCons.py index 791415d4..fec51a47 100644 --- a/etc/TestSCons.py +++ b/etc/TestSCons.py @@ -242,6 +242,33 @@ class TestSCons(TestCommon): kw['match'] = self.match_re_dotall apply(self.run, [], kw) + def skip_test(self, message="Skipping test.\n"): + """Skips a test. + + Proper test-skipping behavior is dependent on whether we're being + executed as part of development of a change under Aegis. + + Technically, skipping a test is a NO RESULT, but Aegis will + treat that as a test failure and prevent the change from going + to the next step. We don't want to force anyone using Aegis + to have to install absolutely every tool used by the tests, + so we actually report to Aegis that a skipped test has PASSED + so that the workflow isn't held up. + """ + if message: + sys.stdout.write(message) + sys.stdout.flush() + devdir = os.popen("aesub '$dd' 2>/dev/null", "r").read()[:-1] + intdir = os.popen("aesub '$intd' 2>/dev/null", "r").read()[:-1] + if devdir and self._cwd[:len(devdir)] == devdir or \ + intdir and self._cwd[:len(intdir)] == intdir: + # We're under the development directory for this change, + # so this is an Aegis invocation; pass the test (exit 0). + self.pass_test() + else: + self.no_result() + + def java_ENV(self): """ Return a default external environment that uses a local Java SDK diff --git a/test/Fortran/F77PATH.py b/test/Fortran/F77PATH.py index e88cdc75..4308bed8 100644 --- a/test/Fortran/F77PATH.py +++ b/test/Fortran/F77PATH.py @@ -39,7 +39,7 @@ args = prog + ' ' + subdir_prog + ' ' + variant_prog test = TestSCons.TestSCons() if not test.detect('F77', 'g77'): - test.pass_test() + test.skip_test('Found no $F77 tool; skipping test.\n') test.subdir('include', 'subdir', ['subdir', 'include'], 'inc2') diff --git a/test/Fortran/F90PATH.py b/test/Fortran/F90PATH.py index 7dbbf2b3..c1b6f490 100644 --- a/test/Fortran/F90PATH.py +++ b/test/Fortran/F90PATH.py @@ -39,16 +39,23 @@ args = prog + ' ' + subdir_prog + ' ' + variant_prog test = TestSCons.TestSCons() -#if not test.detect('F90', 'g90'): -# test.pass_test() -base = '/opt/intel_fc_80' -F90 = os.path.join(base, 'bin', 'ifort') +baselist = [ + '/opt/intel_fc_80', + '/opt/intel/fc/9.0', +] + +F90 = None +for base in baselist: + ifort = os.path.join(base, 'bin', 'ifort') + if os.path.exists(ifort): + F90 = ifort + +if not F90: + l = string.join(baselist, '\n\t') + test.skip_test('No (hard-coded) F90 compiler under:' + l + '\n') + LIBPATH = os.path.join(base, 'lib') LIBS = ['irc'] -if not os.path.exists(F90): - sys.stderr.write('No (hard-coded) F90 compiler %s\n' % F90) - test.no_result(1) - os.environ['LD_LIBRARY_PATH'] = LIBPATH test.subdir('include', 'subdir', ['subdir', 'include'], 'inc2') diff --git a/test/Fortran/FORTRANPATH.py b/test/Fortran/FORTRANPATH.py index ec1b13ec..fc40bf1e 100644 --- a/test/Fortran/FORTRANPATH.py +++ b/test/Fortran/FORTRANPATH.py @@ -39,7 +39,7 @@ args = prog + ' ' + subdir_prog + ' ' + variant_prog test = TestSCons.TestSCons() if not test.detect('F77', 'g77'): - test.pass_test() + test.skip_test('Found no $F77 tool; skipping test.\n') test.subdir('include', 'subdir', ['subdir', 'include'], 'inc2') diff --git a/test/Java/JAR.py b/test/Java/JAR.py index 42f2c5af..f0e3b3ad 100644 --- a/test/Java/JAR.py +++ b/test/Java/JAR.py @@ -126,16 +126,14 @@ if test.detect_tool('javac', ENV=ENV): else: where_javac = test.where_is('javac') if not where_javac: - print "Could not find Java javac, skipping test(s)." - test.pass_test(1) + test.skip_test("Could not find Java javac, skipping test(s).\n") if test.detect_tool('jar', ENV=ENV): where_jar = test.detect('JAR', 'jar', ENV=ENV) else: where_jar = test.where_is('jar') if not where_jar: - print "Could not find Java jar, skipping test(s)." - test.pass_test(1) + test.skip_test("Could not find Java jar, skipping test(s).\n") test.write("wrapper.py", """\ diff --git a/test/Java/JARFLAGS.py b/test/Java/JARFLAGS.py index 9a846ecd..64eb1a43 100644 --- a/test/Java/JARFLAGS.py +++ b/test/Java/JARFLAGS.py @@ -39,16 +39,14 @@ if test.detect_tool('javac', ENV=ENV): else: where_javac = test.where_is('javac') if not where_javac: - print "Could not find Java javac, skipping test(s)." - test.pass_test(1) + test.skip_test("Could not find Java javac, skipping test(s).\n") if test.detect_tool('jar', ENV=ENV): where_jar = test.detect('JAR', 'jar', ENV=ENV) else: where_javac = test.where_is('jar') if not where_jar: - print "Could not find Java jar, skipping test(s)." - test.pass_test(1) + test.skip_test("Could not find Java jar, skipping test(s).\n") test.write('SConstruct', """ env = Environment(tools = ['javac', 'jar'], diff --git a/test/Java/JAVAC.py b/test/Java/JAVAC.py index a89ed528..dd09e35b 100644 --- a/test/Java/JAVAC.py +++ b/test/Java/JAVAC.py @@ -99,8 +99,7 @@ if test.detect_tool('javac', ENV=ENV): else: where_javac = test.where_is('javac') if not where_javac: - print "Could not find Java javac, skipping test(s)." - test.pass_test(1) + test.skip_test("Could not find Java javac, skipping test(s).\n") diff --git a/test/Java/JAVACFLAGS.py b/test/Java/JAVACFLAGS.py index d0ab8479..a237e91f 100644 --- a/test/Java/JAVACFLAGS.py +++ b/test/Java/JAVACFLAGS.py @@ -37,8 +37,7 @@ if test.detect_tool('javac', ENV=ENV): else: where_javac = test.where_is('javac') if not where_javac: - print "Could not find Java javac, skipping test(s)." - test.pass_test(1) + test.skip_test("Could not find Java javac, skipping test(s).\n") test.subdir('src') diff --git a/test/Java/JAVAH.py b/test/Java/JAVAH.py index b70fde03..f9a052eb 100644 --- a/test/Java/JAVAH.py +++ b/test/Java/JAVAH.py @@ -103,8 +103,7 @@ else: if not where_javac: where_javac = env.WhereIs('javac', '/usr/local/j2sdk1.3.1/bin') if not where_javac: - print "Could not find Java javac, skipping test(s)." - test.pass_test(1) + test.skip_test("Could not find Java javac, skipping test(s).\n") if test.detect_tool('javah'): where_javah = test.detect('JAVAH', 'javah') @@ -115,8 +114,7 @@ else: if not where_javah: where_javah = env.WhereIs('javah', '/usr/local/j2sdk1.3.1/bin') if not where_javah: - print "Could not find Java javah, skipping test(s)." - test.pass_test(1) + test.skip_test("Could not find Java javah, skipping test(s).\n") diff --git a/test/PharLap.py b/test/PharLap.py index d9f89934..96525986 100644 --- a/test/PharLap.py +++ b/test/PharLap.py @@ -34,7 +34,7 @@ import time test = TestSCons.TestSCons() if sys.platform != 'win32': - test.pass_test() + test.skip_test('PharLap is only available on win32; skipping test.\n') test.no_result(not test.detect_tool('linkloc')) test.no_result(not test.detect_tool('386asm')) diff --git a/test/Repository/Java.py b/test/Repository/Java.py index fd2986e6..6a45dffd 100644 --- a/test/Repository/Java.py +++ b/test/Repository/Java.py @@ -41,8 +41,7 @@ java = '/usr/local/j2sdk1.3.1/bin/java' javac = '/usr/local/j2sdk1.3.1/bin/javac' if not os.path.exists(javac): - print "Could not find Java, skipping test(s)." - test.pass_test(1) + test.skip_test("Could not find Java, skipping test(s).\n") ############################################################################### diff --git a/test/Repository/JavaH.py b/test/Repository/JavaH.py index c11ad2b4..0420ca37 100644 --- a/test/Repository/JavaH.py +++ b/test/Repository/JavaH.py @@ -42,12 +42,10 @@ javac = '/usr/local/j2sdk1.3.1/bin/javac' javah = '/usr/local/j2sdk1.3.1/bin/javah' if not os.path.exists(javac): - print "Could not find Java (javac), skipping test(s)." - test.pass_test(1) + test.skip_test("Could not find Java (javac), skipping test(s).\n") if not os.path.exists(javah): - print "Could not find Java (javah), skipping test(s)." - test.pass_test(1) + test.skip_test("Could not find Java (javah), skipping test(s).\n") ############################################################################### diff --git a/test/Repository/RMIC.py b/test/Repository/RMIC.py index 9282835d..011006d7 100644 --- a/test/Repository/RMIC.py +++ b/test/Repository/RMIC.py @@ -42,12 +42,10 @@ javac = '/usr/local/j2sdk1.3.1/bin/javac' rmic = '/usr/local/j2sdk1.3.1/bin/rmic' if not os.path.exists(javac): - print "Could not find Java (javac), skipping test(s)." - test.pass_test(1) + test.skip_test("Could not find Java (javac), skipping test(s).\n") if not os.path.exists(rmic): - print "Could not find Java (rmic), skipping test(s)." - test.pass_test(1) + test.skip_test("Could not find Java (rmic), skipping test(s).\n") ###############################################################################