summaryrefslogtreecommitdiff
path: root/solenv/qa
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2016-10-26 12:45:26 +0200
committerBjörn Michaelsen <bjoern.michaelsen@canonical.com>2016-10-26 22:41:32 +0000
commitdd8c8d81de4f361d8f4d259d8a27ac15ab871031 (patch)
treef5f58699b8bac68785b539b1b78940c8be7ccf06 /solenv/qa
parent329ecb67808767d677383e5fd6089feaab4cd9e4 (diff)
add test for running gbuildtoide on non-build modules
- do concat for json in C++, everything else seems fragile on Windows - have APPEND vars separately - check that gbuildtoide work on modules without a full build (modulo some blacklisted "creative" ones) Change-Id: I6fe267fee7d1b77d758072303729387dfeb8e6c8 Reviewed-on: https://gerrit.libreoffice.org/30293 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Diffstat (limited to 'solenv/qa')
-rw-r--r--solenv/qa/python/gbuildtoide.py100
1 files changed, 86 insertions, 14 deletions
diff --git a/solenv/qa/python/gbuildtoide.py b/solenv/qa/python/gbuildtoide.py
index 5216cb0bfcfd..2bd27287b2b9 100644
--- a/solenv/qa/python/gbuildtoide.py
+++ b/solenv/qa/python/gbuildtoide.py
@@ -14,26 +14,46 @@ import json
import os
import os.path
import tempfile
+import shutil
+
+
+# these contortions seem unavoidable for windows
+def getgbuildtesttools(testcase):
+ with open(os.path.join(os.environ['WORKDIR'], 'CustomTarget', 'solenv', 'gbuildtesttools.done'), 'r') as f:
+ gbuildtesttools = json.load(f)
+ testcase.make = gbuildtesttools['MAKE']
+ testcase.bash = gbuildtesttools['BASH']
+ testcase.gbuildtojson = gbuildtesttools['GBUILDTOJSON']
+
+makeenvvars = ['MAKEOVERRIDES', 'MAKEFLAGS', 'MAKE_TERMERR', 'MAKE_TERMOUT', 'MAKELEVEL', 'MFLAGS']
+def clearmakevars():
+ if 'LD_LIBRARY_PATH' in os.environ:
+ del(os.environ['LD_LIBRARY_PATH']) # built with ASAN; prevent that
+ for makeenvvar in makeenvvars:
+ if makeenvvar in os.environ:
+ del os.environ[makeenvvar]
class CheckGbuildToIde(unittest.TestCase):
def setUp(self):
+ getgbuildtesttools(self)
+ clearmakevars()
self.tempwork = tempfile.mkdtemp()
- if os.environ['OS'] == 'WNT':
- self.tempworkmixed = self.tempwork.replace('\\','/')
- else:
- self.tempworkmixed = self.tempwork
def tearDown(self):
- subprocess.check_call(['rm', '-rf', self.tempwork])
+ shutil.rmtree(self.tempwork)
def test_gbuildtoide(self):
- os.chdir(os.path.join(os.environ['SRCDIR'], 'solenv', 'qa', 'python', 'selftest'))
- # make may find instdir/program/libfreebl3.so and fall over if that was
- if 'LD_LIBRARY_PATH' in os.environ:
- del(os.environ['LD_LIBRARY_PATH']) # built with ASAN; prevent that
- make = os.environ['MAKE']
- subprocess.check_call([make, 'gbuildtoide', 'WORKDIR=%s' % self.tempworkmixed])
+ os.makedirs(os.path.join(self.tempwork, 'LinkTarget', 'Executable'))
+ shutil.copy(self.gbuildtojson, os.path.join(self.tempwork, 'LinkTarget', 'Executable'))
+ (bashscripthandle, bashscriptname) = tempfile.mkstemp()
+ bashscript = os.fdopen(bashscripthandle, 'w', newline='\n')
+ bashscript.write("set -e\n")
+ bashscript.write("cd %s/solenv/qa/python/selftest\n" % os.environ['SRCDIR'])
+ bashscript.write("%s gbuildtoide WORKDIR=%s\n" % (self.make, self.tempwork.replace('\\', '/')))
+ bashscript.close()
+ subprocess.check_call([self.bash, bashscriptname.replace('\\', '/')])
+ os.remove(bashscriptname)
jsonfiles = os.listdir(os.path.join(self.tempwork, 'GbuildToIde', 'Library'))
gbuildlibs = []
for jsonfilename in jsonfiles:
@@ -41,7 +61,7 @@ class CheckGbuildToIde(unittest.TestCase):
gbuildlibs.append(json.load(f))
foundlibs = set()
for lib in gbuildlibs:
- self.assertEqual(set(lib.keys()), set(['ASMOBJECTS', 'CFLAGS', 'COBJECTS', 'CXXFLAGS', 'CXXOBJECTS', 'DEFS', 'GENCOBJECTS', 'GENCXXOBJECTS', 'ILIBTARGET', 'INCLUDE', 'LINKED_LIBS', 'LINKED_STATIC_LIBS', 'LINKTARGET', 'OBJCFLAGS', 'OBJCOBJECTS', 'OBJCXXFLAGS', 'OBJCXXOBJECTS', 'YACCOBJECTS']))
+ self.assertEqual(set(lib.keys()), set(['ASMOBJECTS', 'CFLAGS', 'CFLAGSAPPEND', 'CXXFLAGS', 'CXXFLAGSAPPEND', 'CXXOBJECTS', 'DEFS', 'GENCOBJECTS', 'GENCXXOBJECTS', 'ILIBTARGET', 'INCLUDE', 'LINKED_LIBS', 'LINKED_STATIC_LIBS', 'LINKTARGET', 'OBJCFLAGS', 'OBJCFLAGSAPPEND', 'OBJCOBJECTS', 'OBJCXXFLAGS', 'OBJCXXFLAGSAPPEND', 'OBJCXXOBJECTS', 'YACCOBJECTS']))
if lib['LINKTARGET'].find('gbuildselftestdep') != -1:
foundlibs.add('gbuildselftestdep')
elif lib['LINKTARGET'].find('gbuildselftest') != -1:
@@ -50,8 +70,8 @@ class CheckGbuildToIde(unittest.TestCase):
self.assertIn('gbuildselftestdep', lib['LINKED_LIBS'].split())
self.assertIn('solenv/qa/python/selftest/selftestobject', lib['CXXOBJECTS'].split())
self.assertIn('-DGBUILDSELFTESTDEF', lib['DEFS'].split())
- self.assertIn('-DGBUILDSELFTESTCXXFLAG', lib['CXXFLAGS'].split())
- self.assertIn('-DGBUILDSELFTESTCFLAG', lib['CFLAGS'].split())
+ self.assertIn('-DGBUILDSELFTESTCXXFLAG', lib['CXXFLAGSAPPEND'].split())
+ self.assertIn('-DGBUILDSELFTESTCFLAG', lib['CFLAGSAPPEND'].split())
else:
self.assertTrue(False)
self.assertEqual(foundlibs, set(['gbuildselftest', 'gbuildselftestdep']))
@@ -70,6 +90,58 @@ class CheckGbuildToIde(unittest.TestCase):
self.assertEqual(foundexes, set(['gbuildselftestexe']))
self.assertEqual(len(foundexes), 1)
+class CheckGbuildToIdeModules(unittest.TestCase):
+ def setUp(self):
+ getgbuildtesttools(self)
+ clearmakevars()
+ self.tempwork = tempfile.mkdtemp()
+ self.tempsrc = tempfile.mkdtemp()
+ self.srcdir = os.environ['SRCDIR']
+ if os.environ['OS'] == 'WNT':
+ self.tempworkmixed = self.tempwork.replace('\\','/')
+ self.tempsrcmixed = self.tempsrc.replace('\\','/')
+ self.srcdirnative = self.srcdir.replace('/','\\')
+ else:
+ self.tempworkmixed = self.tempwork
+ self.tempsrcmixed = self.tempsrc
+ self.srcdirnative = self.srcdir
+ shutil.copyfile(os.path.join(self.srcdirnative, 'config_host.mk'), os.path.join(self.tempsrc, 'config_host.mk'))
+ shutil.copyfile(os.path.join(self.srcdirnative, 'config_host_lang.mk'), os.path.join(self.tempsrc, 'config_host_lang.mk'))
+ shutil.copyfile(os.path.join(self.srcdirnative, 'Repository.mk'), os.path.join(self.tempsrc, 'Repository.mk'))
+ shutil.copyfile(os.path.join(self.srcdirnative, 'RepositoryExternal.mk'), os.path.join(self.tempsrc, 'RepositoryExternal.mk'))
+ shutil.copyfile(os.path.join(self.srcdirnative, 'RepositoryFixes.mk'), os.path.join(self.tempsrc, 'RepositoryFixes.mk'))
+ shutil.copytree(os.path.join(self.srcdirnative, 'config_host'), os.path.join(self.tempsrc, 'config_host'))
+ print('copytree from _%s_ to _%s_' % (os.path.join(self.srcdirnative, 'solenv').replace('\\', '#').replace('/', '!'), os.path.join(self.tempsrc, 'solenv').replace('\\', '#').replace('/', '!')))
+ shutil.copytree(os.path.join(self.srcdirnative, 'solenv'), os.path.join(self.tempsrc, 'solenv'))
+
+ def tearDown(self):
+ shutil.rmtree(self.tempsrc)
+ shutil.rmtree(self.tempwork)
+
+ def test_gbuildtoide(self):
+ blacklisted_modules = ['compilerplugins', 'cli_ure', 'dictionaries', 'bridges', 'helpcompiler', 'helpcontent2', 'icon-themes', 'sal', 'shell', 'cppu', 'cppuhelper', 'cpputools', 'extensions', 'external', 'i18npool', 'javaunohelper', 'jurt', 'lingucomponent', 'odk', 'scaddins', 'solenv', 'stoc', 'tools', 'tranlations', 'writerfilter']
+ modules = ['accessibility', 'android', 'animations', 'apple_remote', 'avmedia', 'basctl', 'basegfx', 'basic', 'bean', 'canvas', 'chart2', 'codemaker', 'comphelper', 'cppcanvas', 'cui', 'dbaccess', 'desktop', 'drawinglayer', 'dtrans', 'editeng', 'embeddedobj', 'embedserv', 'eventattacher', 'extras', 'filter', 'forms', 'formula', 'fpicker', 'framework', 'hwpfilter', 'i18nlangtag', 'i18nutil', 'idl', 'idlc', 'instsetoo_native', 'io', 'ios', 'jvmaccess', 'jvmfwk', 'l10ntools', 'librelogo', 'libreofficekit', 'linguistic', 'lotuswordpro', 'mysqlc', 'nlpsolver', 'o3tl', 'offapi', 'officecfg', 'onlineupdate', 'oovbaapi', 'oox', 'opencl', 'package', 'postprocess', 'pyuno', 'registry', 'remotebridges', 'reportbuilder', 'reportdesign', 'ridljar', 'rsc', 'salhelper', 'sax', 'sc', 'sccomp', 'scp2', 'scripting', 'sd', 'sdext', 'setup_native', 'sfx2', 'slideshow', 'smoketest', 'soltools', 'sot', 'starmath', 'store', 'svgio', 'svl', 'svtools', 'svx', 'sw', 'swext', 'sysui', 'test', 'testtools', 'toolkit', 'tubes', 'ucb', 'ucbhelper', 'udkapi', 'uitest', 'UnoControls', 'unodevtools', 'unoidl', 'unoil', 'unotest', 'unotools', 'unoxml', 'ure', 'uui', 'vbahelper', 'vcl', 'winaccessibility', 'wizards', 'writerperfect', 'xmerge', 'xmlhelp', 'xmloff', 'xmlreader', 'xmlscript', 'xmlsecurity']
+ for module in modules:
+ shutil.rmtree(self.tempwork)
+ os.makedirs(os.path.join(self.tempwork, 'LinkTarget', 'Executable'))
+ shutil.copy(self.gbuildtojson, os.path.join(self.tempwork, 'LinkTarget', 'Executable'))
+ if module != 'solenv':
+ shutil.copytree(os.path.join(os.environ['SRCDIR'], module), os.path.join(self.tempsrc, module))
+ (bashscripthandle, bashscriptname) = tempfile.mkstemp()
+ bashscript = os.fdopen(bashscripthandle, 'w', newline='\n')
+ bashscript.write("set -e\n")
+ bashscript.write("cd %s/%s\n" % (self.tempsrc.replace('\\','/'), module))
+ bashscript.write("%s gbuildtoide WORKDIR=%s SRCDIR=%s\n" % (self.make, self.tempwork.replace('\\', '/'), self.tempsrc.replace('\\','/')))
+ bashscript.close()
+ subprocess.check_call([self.bash, bashscriptname.replace('\\', '/')])
+ os.remove(bashscriptname)
+ jsonfiles = os.listdir(os.path.join(self.tempwork, 'GbuildToIde', 'Library'))
+ gbuildlibs = []
+ for jsonfilename in jsonfiles:
+ with open(os.path.join(self.tempwork, 'GbuildToIde', 'Library', jsonfilename), 'r') as f:
+ gbuildlibs.append(json.load(f))
+
+
if __name__ == "__main__":
unittest.main()