summaryrefslogtreecommitdiff
path: root/testing/framework/TestSConsign.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-14 08:35:35 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-14 08:35:35 +0200
commitb4de7f5943eb16fa393df953e97eb2ba8cc35df1 (patch)
tree20239aec5f6b0ec44acd691ad98e1a4b38957c8b /testing/framework/TestSConsign.py
parent85dbcc01ae3f6b10849aa71faef6946d8e16d55f (diff)
parent697e33ed224b539a42ff68121f7497f5bbf941b2 (diff)
Update upstream source from tag 'upstream/3.0.5'
Update to upstream version '3.0.5' with Debian dir 03c2cf71b97fe65fcfd82c7f4a3862fe2b35614d
Diffstat (limited to 'testing/framework/TestSConsign.py')
-rw-r--r--testing/framework/TestSConsign.py90
1 files changed, 90 insertions, 0 deletions
diff --git a/testing/framework/TestSConsign.py b/testing/framework/TestSConsign.py
new file mode 100644
index 0000000..fc72aa4
--- /dev/null
+++ b/testing/framework/TestSConsign.py
@@ -0,0 +1,90 @@
+# Copyright (c) 2001 - 2019 The SCons Foundation
+from __future__ import print_function
+
+__revision__ = "testing/framework/TestSConsign.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+
+__doc__ = """
+TestSConsign.py: a testing framework for the "sconsign" script
+tool.
+
+A TestSConsign environment object is created via the usual invocation:
+
+ test = TestSConsign()
+
+TestSconsign is a subclass of TestSCons, which is a subclass of
+TestCommon, which is in turn is a subclass of TestCmd), and hence
+has available all of the methods and attributes from those classes,
+as well as any overridden or additional methods or attributes defined
+in this subclass.
+"""
+
+import os
+import os.path
+import sys
+
+from TestSCons import *
+from TestSCons import __all__
+
+__all__.extend([ 'TestSConsign', ])
+
+class TestSConsign(TestSCons):
+ """Class for testing the sconsign.py script.
+
+ This provides a common place for initializing sconsign tests,
+ eliminating the need to begin every test with the same repeated
+ initializations.
+
+ This adds additional methods for running the sconsign script
+ without changing the basic ability of the run() method to run
+ "scons" itself, since we need to run scons to generate the
+ .sconsign files that we want the sconsign script to read.
+ """
+ def __init__(self, *args, **kw):
+ try:
+ script_dir = os.environ['SCONS_SCRIPT_DIR']
+ except KeyError:
+ pass
+ else:
+ os.chdir(script_dir)
+ self.script_dir = os.getcwd()
+
+ TestSCons.__init__(self, *args, **kw)
+
+ self.my_kw = {
+ 'interpreter' : python, # imported from TestSCons
+ }
+
+ if 'program' not in kw:
+ kw['program'] = os.environ.get('SCONS')
+ if not kw['program']:
+ if os.path.exists('scons'):
+ kw['program'] = 'scons'
+ else:
+ kw['program'] = 'scons.py'
+
+ sconsign = os.environ.get('SCONSIGN')
+ if not sconsign:
+ if os.path.exists(self.script_path('sconsign.py')):
+ sconsign = 'sconsign.py'
+ elif os.path.exists(self.script_path('sconsign')):
+ sconsign = 'sconsign'
+ else:
+ print("Can find neither 'sconsign.py' nor 'sconsign' scripts.")
+ self.no_result()
+ self.set_sconsign(sconsign)
+
+ def script_path(self, script):
+ return os.path.join(self.script_dir, script)
+
+ def set_sconsign(self, sconsign):
+ self.my_kw['program'] = sconsign
+
+ def run_sconsign(self, *args, **kw):
+ kw.update(self.my_kw)
+ return self.run(*args, **kw)
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: