diff options
Diffstat (limited to 'test/packaging')
-rw-r--r-- | test/packaging/guess-package-name.py | 106 | ||||
-rw-r--r-- | test/packaging/ipkg.py | 129 | ||||
-rw-r--r-- | test/packaging/msi/file-placement.py | 172 | ||||
-rw-r--r-- | test/packaging/msi/package.py | 138 | ||||
-rw-r--r-- | test/packaging/option--package-type.py | 78 | ||||
-rw-r--r-- | test/packaging/place-files-in-subdirectory.py | 108 | ||||
-rw-r--r-- | test/packaging/rpm/cleanup.py | 100 | ||||
-rw-r--r-- | test/packaging/rpm/internationalization.py | 180 | ||||
-rw-r--r-- | test/packaging/rpm/package.py | 91 | ||||
-rw-r--r-- | test/packaging/rpm/tagging.py | 97 | ||||
-rw-r--r-- | test/packaging/sandbox-test.py | 73 | ||||
-rw-r--r-- | test/packaging/strip-install-dir.py | 60 | ||||
-rw-r--r-- | test/packaging/tar/bz2.py | 64 | ||||
-rw-r--r-- | test/packaging/tar/gz.py | 64 | ||||
-rw-r--r-- | test/packaging/use-builddir.py | 93 | ||||
-rw-r--r-- | test/packaging/zip.py | 65 |
16 files changed, 1618 insertions, 0 deletions
diff --git a/test/packaging/guess-package-name.py b/test/packaging/guess-package-name.py new file mode 100644 index 0000000..5b4cd67 --- /dev/null +++ b/test/packaging/guess-package-name.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +This tests the feature of guessing the package name from the given metadata +projectname and version. + +Also overriding this default package name is tested + +Furthermore that targz is the default packager is tested. +""" + +import os +import TestSCons + +python = TestSCons.python +test = TestSCons.TestSCons() +tar = test.detect('TAR', 'tar') + +if not tar: + test.skip_test('tar not found; skipping test\n') + +# +# TEST: default package name creation. +# +test.subdir('src') + +test.write( [ 'src', 'main.c' ], r""" +int main( int argc, char* argv[] ) +{ + return 0; +} +""") + +test.write('SConstruct', """ +env=Environment(tools=['default', 'packaging']) +env.Program( 'src/main.c' ) +env.Package( NAME = 'libfoo', + VERSION = '1.2.3', + PACKAGETYPE = 'zip', + source = [ 'src/main.c', 'SConstruct' ] ) +""") + +test.run(options="--debug=stacktrace", stderr = None) + +test.must_exist( 'libfoo-1.2.3.zip' ) + +# +# TEST: overriding default package name. +# + +test.write('SConstruct', """ +env=Environment(tools=['default', 'packaging']) +env.Program( 'src/main.c' ) +env.Package( NAME = 'libfoo', + VERSION = '1.2.3', + PACKAGETYPE = 'src_targz', + target = 'src.tar.gz', + source = [ 'src/main.c', 'SConstruct' ] ) +""") + +test.run(stderr = None) + +test.must_exist( 'src.tar.gz' ) + +# +# TEST: default package name creation with overriden packager. +# + +test.write('SConstruct', """ +env=Environment(tools=['default', 'packaging']) +env.Program( 'src/main.c' ) +env.Package( NAME = 'libfoo', + VERSION = '1.2.3', + PACKAGETYPE = 'src_tarbz2', + source = [ 'src/main.c', 'SConstruct' ] ) +""") + +test.run(stderr = None) + +test.must_exist( 'libfoo-1.2.3.tar.bz2' ) + +test.pass_test() diff --git a/test/packaging/ipkg.py b/test/packaging/ipkg.py new file mode 100644 index 0000000..62ce628 --- /dev/null +++ b/test/packaging/ipkg.py @@ -0,0 +1,129 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the ability to call the ipkg tool trough SCons. + +TODO: make a test to assert that the clean action removes ALL intermediate files +""" + +import os +import TestSCons + +python = TestSCons.python +test = TestSCons.TestSCons() +ipkg = test.Environment().WhereIs('ipkg-build') + +if not ipkg: + test.skip_test("ipkg-build not found, skipping test\n") + +test.write( 'main.c', r""" +int main(int argc, char *argv[]) +{ + return 0; +} +""") + +test.write( 'foo.conf', '' ) + +test.write( 'SConstruct', r""" +env=Environment(tools=['default', 'packaging']) +prog = env.Install( 'bin/', Program( 'main.c') ) +conf = env.Install( 'etc/', File( 'foo.conf' ) ) +env.Tag( conf, 'CONF', 'MEHR', 'UND MEHR' ) +env.Package( PACKAGETYPE = 'ipk', + source = env.FindInstalledFiles(), + NAME = 'foo', + VERSION = '0.0', + SUMMARY = 'foo is the ever-present example program -- it does everything', + DESCRIPTION = '''foo is not a real package. This is simply an example that you +may modify if you wish. +. +When you modify this example, be sure to change the Package, Version, +Maintainer, Depends, and Description fields.''', + + SOURCE_URL = 'http://gnu.org/foo-0.0.tar.gz', + X_IPK_SECTION = 'extras', + X_IPK_PRIORITY = 'optional', + ARCHITECTURE = 'arm', + X_IPK_MAINTAINER = 'Familiar User <user@somehost.net>', + X_IPK_DEPENDS = 'libc6, grep', ) +""") + +expected="""scons: Reading SConscript files ... +scons: done reading SConscript files. +scons: Building targets ... +gcc -o main.o -c main.c +gcc -o main main.o +Copy file(s): "main" to "foo-0.0/bin/main" +Copy file(s): "foo.conf" to "foo-0.0/etc/foo.conf" +build_specfiles(["foo-0.0/CONTROL/control", "foo-0.0/CONTROL/conffiles", "foo-0.0/CONTROL/postrm", "foo-0.0/CONTROL/prerm", "foo-0.0/CONTROL/postinst", "foo-0.0/CONTROL/preinst"], ["foo-0.0/bin/main", "foo-0.0/etc/foo.conf"]) +ipkg-build -o %s -g %s foo-0.0 +Packaged contents of foo-0.0 into %s/foo_0.0_arm.ipk +scons: done building targets. +"""%(os.popen('id -un').read().strip(), os.popen('id -gn').read().strip(), test.workpath()) + +test.run(arguments="--debug=stacktrace foo_0.0_arm.ipk", stdout=expected) +test.must_exist( 'foo-0.0/CONTROL/control' ) +test.must_exist( 'foo_0.0_arm.ipk' ) + +test.subdir( 'foo-0.0' ) +test.subdir( [ 'foo-0.0', 'CONTROL' ] ) + +test.write( [ 'foo-0.0', 'CONTROL', 'control' ], r""" +Package: foo +Priority: optional +Section: extras +Source: http://gnu.org/foo-0.0.tar.gz +Version: 0.0 +Architecture: arm +Maintainer: Familiar User <user@somehost.net> +Depends: libc6, grep +Description: foo is the ever-present example program -- it does everything + foo is not a real package. This is simply an example that you + may modify if you wish. + . + When you modify this example, be sure to change the Package, Version, + Maintainer, Depends, and Description fields. +""") + +test.write( 'main.c', r""" +int main(int argc, char *argv[]) +{ + return 0; +} +""") + +test.write('SConstruct', """ +env = Environment( tools = [ 'default', 'ipkg' ] ) +prog = env.Install( 'foo-0.0/bin/' , env.Program( 'main.c') ) +env.Ipkg( [ env.Dir( 'foo-0.0' ), prog ] ) +""") + +test.run(arguments='', stderr = None) +test.must_exist( 'foo_0.0_arm.ipk' ) + +test.pass_test() diff --git a/test/packaging/msi/file-placement.py b/test/packaging/msi/file-placement.py new file mode 100644 index 0000000..08b0ba6 --- /dev/null +++ b/test/packaging/msi/file-placement.py @@ -0,0 +1,172 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the msi packagers ability to put files into distinct directories. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +try: + from xml.dom.minidom import * +except ImportError: + test.skip_test('Canoot import xml.dom.minidom skipping test\n') + +wix = test.Environment().WhereIs('candle') + +if wix: + # + # Test the default directory layout + # + test.write( 'file1.exe', "file1" ) + + test.write('SConstruct', """ +env = Environment(tools=['default', 'packaging']) +f1 = env.Install( '/bin/' , 'file1.exe' ) + +env.Package( NAME = 'foo', + VERSION = '1.2', + PACKAGETYPE = 'msi', + SUMMARY = 'balalalalal', + DESCRIPTION = 'this should be reallly really long', + VENDOR = 'Nanosoft_2000', + source = [ f1 ], + ) +""") + + test.run(arguments='', stderr = None) + + dom = parse( test.workpath( 'foo-1.2.wxs' ) ) + dirs = dom.getElementsByTagName( 'Directory' ) + + test.fail_test( not dirs[0].attributes['Name'].value == 'SourceDir' ) + test.fail_test( not dirs[1].attributes['Name'].value == 'PFiles' ) + test.fail_test( not dirs[2].attributes['Name'].value == 'NANOSOF1' ) + test.fail_test( not dirs[3].attributes['Name'].value == 'FOO-1.2' ) + + # + # Try to put 7 files into 5 distinct directories of varying depth and overlapping count + # + test.write( 'file1.exe', "file1" ) + test.write( 'file2.exe', "file2" ) + test.write( 'file3.dll', "file3" ) + test.write( 'file4.dll', "file4" ) + test.write( 'file5.class', "file5" ) + test.write( 'file6.class', "file6" ) + test.write( 'file7.class', "file7" ) + + test.write('SConstruct', """ +env = Environment(tools=['default', 'packaging']) +f1 = env.Install( '/bin/' , 'file1.exe' ) +f2 = env.Install( '/bin/' , 'file2.exe' ) +f3 = env.Install( '/lib/' , 'file3.dll' ) +f4 = env.Install( '/lib/' , 'file4.dll' ) +f5 = env.Install( '/java/edu/teco/' , 'file5.class' ) +f6 = env.Install( '/java/teco/' , 'file6.class' ) +f7 = env.Install( '/java/tec/' , 'file7.class' ) + +env.Package( NAME = 'foo', + VERSION = '1.2', + PACKAGETYPE = 'msi', + SUMMARY = 'balalalalal', + DESCRIPTION = 'this should be reallly really long', + VENDOR = 'Nanosoft_2000', + LICENSE = 'afl', + source = [ f1, f2, f3, f4, f5, f6, f7 ], + ) +""") + + test.run(arguments='', stderr = None) + + dom = parse( test.workpath( 'foo-1.2.wxs' ) ) + files = dom.getElementsByTagName( 'File' ) + + test.fail_test( not files[0].parentNode.parentNode.attributes['LongName'].value == 'bin' ) + test.fail_test( not files[1].parentNode.parentNode.attributes['LongName'].value == 'bin' ) + test.fail_test( not files[2].parentNode.parentNode.attributes['LongName'].value == 'lib' ) + test.fail_test( not files[3].parentNode.parentNode.attributes['LongName'].value == 'lib' ) + + test.fail_test( not files[4].parentNode.parentNode.attributes['LongName'].value == 'teco' ) + test.fail_test( not files[4].parentNode.parentNode.parentNode.attributes['LongName'].value == 'edu' ) + test.fail_test( not files[4].parentNode.parentNode.parentNode.parentNode.attributes['LongName'].value == 'java' ) + + test.fail_test( not files[5].parentNode.parentNode.attributes['LongName'].value == 'teco' ) + test.fail_test( not files[5].parentNode.parentNode.parentNode.attributes['LongName'].value == 'java' ) + + test.fail_test( not files[6].parentNode.parentNode.attributes['LongName'].value == 'tec' ) + test.fail_test( not files[6].parentNode.parentNode.parentNode.attributes['LongName'].value == 'java' ) + + # + # Test distinct directories put into distinct features + # + test.write( 'file1.exe', "file1" ) + test.write( 'file2.exe', "file2" ) + test.write( 'file3.dll', "file3" ) + test.write( 'file3-.dll', "file3" ) + + test.write('SConstruct', """ +env = Environment(tools=['default', 'packaging']) +f1 = env.Install( '/bin/' , 'file1.exe' ) +f2 = env.Install( '/bin/' , 'file2.exe' ) +f3 = env.Install( '/lib/' , 'file3.dll' ) +f4 = env.Install( '/lib/' , 'file3-.dll' ) # generate a collision in the ids + +env.Tag( [f1, f2, f4], X_MSI_FEATURE = 'Core Part' ) +env.Tag( f3, X_MSI_FEATURE = 'Java Part' ) + +env.Package( NAME = 'foo', + VERSION = '1.2', + PACKAGETYPE = 'msi', + SUMMARY = 'balalalalal', + DESCRIPTION = 'this should be reallly really long', + VENDOR = 'Nanosoft_2000', + LICENSE = 'afl', + source = [ f1, f2, f3, f4 ], + ) +""") + + test.run(arguments='', stderr = None) + + dom = parse( test.workpath( 'foo-1.2.wxs' ) ) + features = dom.getElementsByTagName( 'Feature' ) + + test.fail_test( not features[1].attributes['Title'].value == 'Core Part' ) + componentrefs = features[1].getElementsByTagName( 'ComponentRef' ) + test.fail_test( not componentrefs[0].attributes['Id'].value == 'file1.exe' ) + test.fail_test( not componentrefs[1].attributes['Id'].value == 'file2.exe' ) + test.fail_test( not componentrefs[2].attributes['Id'].value == 'file3.dll1' ) + + test.fail_test( not features[2].attributes['Title'].value == 'Java Part' ) + componentrefs = features[2].getElementsByTagName( 'ComponentRef' ) + test.fail_test( not componentrefs[0].attributes['Id'].value == 'file3.dll' ) + +else: + test.no_result() + diff --git a/test/packaging/msi/package.py b/test/packaging/msi/package.py new file mode 100644 index 0000000..24bd26d --- /dev/null +++ b/test/packaging/msi/package.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the ability to create a simple msi package. +""" + +import os +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +try: + from xml.dom.minidom import * +except ImportError: + test.skip_test('Canoot import xml.dom.minidom skipping test\n') + +wix = test.Environment().WhereIs('candle') + +if wix: + # + # build with minimal tag set and test for the given package meta-data + # + test.write( 'file1.exe', "file1" ) + test.write( 'file2.exe', "file2" ) + + test.write('SConstruct', """ +import os + +env = Environment(tools=['default', 'packaging']) + +f1 = env.Install( '/usr/' , 'file1.exe' ) +f2 = env.Install( '/usr/' , 'file2.exe' ) + +env.Package( NAME = 'foo', + VERSION = '1.2', + PACKAGETYPE = 'msi', + SUMMARY = 'balalalalal', + DESCRIPTION = 'this should be reallly really long', + VENDOR = 'Nanosoft_2000', + source = [ f1, f2 ], + ) + +env.Alias( 'install', [ f1, f2 ] ) +""") + + test.run(arguments='', stderr = None) + + test.must_exist( 'foo-1.2.wxs' ) + test.must_exist( 'foo-1.2.msi' ) + + dom = parse( test.workpath( 'foo-1.2.wxs' ) ) + Product = dom.getElementsByTagName( 'Product' )[0] + Package = dom.getElementsByTagName( 'Package' )[0] + + test.fail_test( not Product.attributes['Manufacturer'].value == 'Nanosoft_2000' ) + test.fail_test( not Product.attributes['Version'].value == '1.2' ) + test.fail_test( not Product.attributes['Name'].value == 'foo' ) + + test.fail_test( not Package.attributes['Description'].value == 'balalalalal' ) + test.fail_test( not Package.attributes['Comments'].value == 'this should be reallly really long' ) + + # + # build with file tags resulting in multiple components in the msi installer + # + test.write( 'file1.exe', "file1" ) + test.write( 'file2.exe', "file2" ) + test.write( 'file3.html', "file3" ) + test.write( 'file4.dll', "file4" ) + test.write( 'file5.dll', "file5" ) + + test.write('SConstruct', """ +import os +env = Environment(tools=['default', 'packaging']) +f1 = env.Install( '/usr/' , 'file1.exe' ) +f2 = env.Install( '/usr/' , 'file2.exe' ) +f3 = env.Install( '/usr/' , 'file3.html' ) +f4 = env.Install( '/usr/' , 'file4.dll' ) +f5 = env.Install( '/usr/' , 'file5.dll' ) + +env.Tag( f1, X_MSI_FEATURE = 'Java Part' ) +env.Tag( f2, X_MSI_FEATURE = 'Java Part' ) +env.Tag( f3, 'DOC' ) +env.Tag( f4, X_MSI_FEATURE = 'default' ) +env.Tag( f5, X_MSI_FEATURE = ('Another Feature', 'with a long description') ) + +env.Package( NAME = 'foo', + VERSION = '1.2', + PACKAGETYPE = 'msi', + SUMMARY = 'balalalalal', + DESCRIPTION = 'this should be reallly really long', + VENDOR = 'Nanosoft_tx2000', + source = [ f1, f2, f3, f4, f5 ], + ) + +env.Alias( 'install', [ f1, f2, f3, f4, f5 ] ) +""") + + test.run(arguments='', stderr = None) + + test.must_exist( 'foo-1.2.wxs' ) + test.must_exist( 'foo-1.2.msi' ) + + dom = parse( test.workpath( 'foo-1.2.wxs' ) ) + elements = dom.getElementsByTagName( 'Feature' ) + test.fail_test( not elements[1].attributes['Title'].value == 'Main Part' ) + test.fail_test( not elements[2].attributes['Title'].value == 'Documentation' ) + test.fail_test( not elements[3].attributes['Title'].value == 'Another Feature' ) + test.fail_test( not elements[3].attributes['Description'].value == 'with a long description' ) + test.fail_test( not elements[4].attributes['Title'].value == 'Java Part' ) + +else: + test.no_result() diff --git a/test/packaging/option--package-type.py b/test/packaging/option--package-type.py new file mode 100644 index 0000000..68a075c --- /dev/null +++ b/test/packaging/option--package-type.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the --package-type option. +""" + +import TestSCons + +machine = TestSCons.machine +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +scons = test.program + +rpm = test.Environment().WhereIs('rpm') + +if not rpm: + test.skip_test('rpm not found, skipping test\n') + +test.subdir('src') + +test.write( 'main', '' ) + +test.write('SConstruct', """ +# -*- coding: iso-8859-15 -*- +env=Environment(tools=['default', 'packaging']) +env.Prepend(RPM = 'TAR_OPTIONS=--wildcards ') +prog=env.Install( '/bin', 'main' ) +env.Package( NAME = 'foo', + VERSION = '1.2.3', + LICENSE = 'gpl', + SUMMARY = 'hello', + PACKAGEVERSION = 0, + X_RPM_GROUP = 'Application/office', + X_RPM_INSTALL = r'%(_python_)s %(scons)s --install-sandbox="$RPM_BUILD_ROOT" "$RPM_BUILD_ROOT"', + DESCRIPTION = 'this should be really long', + source = [ prog ], + SOURCE_URL = 'http://foo.org/foo-1.2.3.tar.gz' + ) +""" % locals()) + +test.run(arguments='package PACKAGETYPE=rpm', stderr = None) + +src_rpm = 'foo-1.2.3-0.src.rpm' +machine_rpm = 'foo-1.2.3-0.%s.rpm' % machine + +test.must_exist( src_rpm ) +test.must_exist( machine_rpm ) + +test.must_not_exist( 'bin/main.c' ) +test.must_not_exist( '/bin/main.c' ) + +test.pass_test() diff --git a/test/packaging/place-files-in-subdirectory.py b/test/packaging/place-files-in-subdirectory.py new file mode 100644 index 0000000..d9758a1 --- /dev/null +++ b/test/packaging/place-files-in-subdirectory.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the requirement to place files in a given subdirectory before archiving. +""" + +import os +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +tar = test.detect('TAR', 'tar') + +if not tar: + test.skipt_test('tar not found, skipping test\n') + +# +# TEST: subdir creation and file copying +# +test.subdir('src') + +test.write('src/main.c', '') + +test.write('SConstruct', """ +env = Environment(tools=['default', 'packaging']) +env.Package( NAME = 'libfoo', + PACKAGEROOT = 'libfoo', + PACKAGETYPE = 'src_zip', + VERSION = '1.2.3', + source = [ 'src/main.c', 'SConstruct' ] ) +""") + +test.run(arguments='libfoo-1.2.3.zip', stderr = None) + +test.must_exist( 'libfoo' ) +test.must_exist( 'libfoo/SConstruct' ) +test.must_exist( 'libfoo/src/main.c' ) + +# +# TEST: subdir guessing and file copying. +# +test.subdir('src') + +test.write('src/main.c', '') + +test.write('SConstruct', """ +env = Environment(tools=['default', 'packaging']) +env.Package( NAME = 'libfoo', + VERSION = '1.2.3', + PACKAGETYPE = 'src_zip', + TARGET = 'src.zip', + source = [ 'src/main.c', 'SConstruct' ] ) +""") + +test.run(stderr = None) + +test.must_exist( 'libfoo-1.2.3' ) +test.must_exist( 'libfoo-1.2.3/SConstruct' ) +test.must_exist( 'libfoo-1.2.3/src/main.c' ) + +# +# TEST: unpacking without the buildir. +# +test.subdir('src') +test.subdir('temp') + +test.write('src/main.c', '') + +test.write('SConstruct', """ +env = Environment(tools=['default', 'packaging']) +env.Package( NAME = 'libfoo', + VERSION = '1.2.3', + PACKAGETYPE = 'src_targz', + source = [ 'src/main.c', 'SConstruct' ] ) +""") + +test.run(stderr = None) + +str = os.popen( 'tar -tzf %s'%test.workpath('libfoo-1.2.3.tar.gz') ).read() +test.fail_test( str != "libfoo-1.2.3/src/main.c\nlibfoo-1.2.3/SConstruct\n" ) + +test.pass_test() diff --git a/test/packaging/rpm/cleanup.py b/test/packaging/rpm/cleanup.py new file mode 100644 index 0000000..26bf79b --- /dev/null +++ b/test/packaging/rpm/cleanup.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Assert that files created by the RPM packager will be removed by 'scons -c'. +""" + +import TestSCons + +machine = TestSCons.machine +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +scons = test.program + +# TODO: skip this test, since only the intermediate directory needs to be +# removed. + +rpm = test.Environment().WhereIs('rpm') + +if not rpm: + test.skip_test('rpm not found, skipping test\n') + +test.subdir('src') + +test.write( [ 'src', 'main.c' ], r""" +int main( int argc, char* argv[] ) +{ + return 0; +} +""") + +test.write('SConstruct', """ +env=Environment(tools=['default', 'packaging']) + +env.Prepend(RPM = 'TAR_OPTIONS=--wildcards ') + +prog = env.Install( '/bin/' , Program( 'src/main.c') ) + +env.Package( NAME = 'foo', + VERSION = '1.2.3', + PACKAGEVERSION = 0, + PACKAGETYPE = 'rpm', + LICENSE = 'gpl', + SUMMARY = 'balalalalal', + X_RPM_GROUP = 'Application/fu', + X_RPM_INSTALL = r'%(_python_)s %(scons)s --install-sandbox="$RPM_BUILD_ROOT" "$RPM_BUILD_ROOT"', + DESCRIPTION = 'this should be really really long', + source = [ prog ], + SOURCE_URL = 'http://foo.org/foo-1.2.3.tar.gz' + ) + +env.Alias( 'install', prog ) +""" % locals()) + +# first run: build the package +# second run: test if the intermediate files have been cleaned +test.run( arguments='' ) +test.run( arguments='-c' ) + +src_rpm = 'foo-1.2.3-0.src.rpm' +machine_rpm = 'foo-1.2.3-0.%s.rpm' % machine + +test.must_not_exist( machine_rpm ) +test.must_not_exist( src_rpm ) +test.must_not_exist( 'foo-1.2.3.tar.gz' ) +test.must_not_exist( 'foo-1.2.3.spec' ) +test.must_not_exist( 'foo-1.2.3/foo-1.2.3.spec' ) +test.must_not_exist( 'foo-1.2.3/SConstruct' ) +test.must_not_exist( 'foo-1.2.3/src/main.c' ) +# We don't remove the directories themselves. Yet. +#test.must_not_exist( 'foo-1.2.3' ) +#test.must_not_exist( 'foo-1.2.3/src' ) +test.must_not_exist( 'bin/main' ) + +test.pass_test() diff --git a/test/packaging/rpm/internationalization.py b/test/packaging/rpm/internationalization.py new file mode 100644 index 0000000..66c2291 --- /dev/null +++ b/test/packaging/rpm/internationalization.py @@ -0,0 +1,180 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the ability to handle internationalized package and file meta-data. + +These are x-rpm-Group, description, summary and the lang_xx file tag. +""" + +import os + +import TestSCons + +machine = TestSCons.machine +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +scons = test.program + +rpm = test.Environment().WhereIs('rpm') + +if not rpm: + test.skip_test('rpm not found, skipping test\n') + +# +# test INTERNATIONAL PACKAGE META-DATA +# +test.write( [ 'main.c' ], r""" +int main( int argc, char* argv[] ) +{ + return 0; +} +""") + +test.write('SConstruct', """ +# -*- coding: utf-8 -*- +import os + +env = Environment(tools=['default', 'packaging']) + +env.Prepend(RPM = 'TAR_OPTIONS=--wildcards ') + +prog = env.Install( '/bin', Program( 'main.c' ) ) + +env.Package( NAME = 'foo', + VERSION = '1.2.3', + PACKAGETYPE = 'rpm', + LICENSE = 'gpl', + SUMMARY = 'hello', + SUMMARY_de = 'hallo', + SUMMARY_fr = 'bonjour', + PACKAGEVERSION = 0, + X_RPM_GROUP = 'Application/office', + X_RPM_GROUP_de = 'Applikation/büro', + X_RPM_GROUP_fr = 'Application/bureau', + X_RPM_INSTALL = r'%(_python_)s %(scons)s --install-sandbox="$RPM_BUILD_ROOT" "$RPM_BUILD_ROOT"', + DESCRIPTION = 'this should be really long', + DESCRIPTION_de = 'das sollte wirklich lang sein', + DESCRIPTION_fr = 'ceci devrait être vraiment long', + source = [ prog ], + SOURCE_URL = 'http://foo.org/foo-1.2.3.tar.gz' + ) + +env.Alias ( 'install', prog ) +""" % locals()) + +test.run(arguments='', stderr = None) + +src_rpm = 'foo-1.2.3-0.src.rpm' +machine_rpm = 'foo-1.2.3-0.%s.rpm' % machine + +test.must_exist( src_rpm ) +test.must_exist( machine_rpm ) + +test.must_not_exist( 'bin/main' ) + +cmd = 'rpm -qp --queryformat \'%%{GROUP}-%%{SUMMARY}-%%{DESCRIPTION}\' %s' + +os.environ['LC_ALL'] = 'de_DE.utf8' +os.environ['LANGUAGE'] = 'de' +out = os.popen( cmd % test.workpath(machine_rpm) ).read() +test.fail_test( out != 'Applikation/büro-hallo-das sollte wirklich lang sein' ) + +os.environ['LC_ALL'] = 'fr_FR.utf8' +os.environ['LANGUAGE'] = 'fr' +out = os.popen( cmd % test.workpath(machine_rpm) ).read() +test.fail_test( out != 'Application/bureau-bonjour-ceci devrait être vraiment long' ) + +os.environ['LANGUAGE'] = 'en' +out = os.popen( cmd % test.workpath(machine_rpm) ).read() +test.fail_test( out != 'Application/office-hello-this should be really long' ) + +os.environ['LC_ALL'] = 'ae' +out = os.popen( cmd % test.workpath(machine_rpm) ).read() +test.fail_test( out != 'Application/office-hello-this should be really long' ) + +# +# test INTERNATIONAL PACKAGE TAGS +# + +test.write( [ 'main.c' ], r""" +int main( int argc, char* argv[] ) +{ + return 0; +} +""") + +test.write( ['man.de'], '' ) +test.write( ['man.en'], '' ) +test.write( ['man.fr'], '' ) + +test.write('SConstruct', """ +# -*- coding: utf-8 -*- +import os + +env = Environment(tools=['default', 'packaging']) +prog = env.Install( '/bin', Program( 'main.c' ) ) + +man_pages = Flatten( [ + env.Install( '/usr/share/man/de', 'man.de' ), + env.Install( '/usr/share/man/en', 'man.en' ), + env.Install( '/usr/share/man/fr', 'man.fr' ) +] ) + +env.Tag( man_pages, 'LANG_DE', 'DOC') + +env.Package( NAME = 'foo', + VERSION = '1.2.3', + PACKAGETYPE = 'rpm', + LICENSE = 'gpl', + SUMMARY = 'hello', + SUMMARY_de = 'hallo', + SUMMARY_fr = 'bonjour', + PACKAGEVERSION = 0, + X_RPM_GROUP = 'Application/office', + X_RPM_GROUP_de = 'Applikation/büro', + X_RPM_GROUP_fr = 'Application/bureau', + X_RPM_INSTALL = r'%(_python_)s %(scons)s --install-sandbox="$RPM_BUILD_ROOT" "$RPM_BUILD_ROOT"', + DESCRIPTION = 'this should be really long', + DESCRIPTION_de = 'das sollte wirklich lang sein', + DESCRIPTION_fr = 'ceci devrait être vraiment long', + source = [ prog, man_pages ], + SOURCE_URL = 'http://foo.org/foo-1.2.3.tar.gz', + ) + +env.Alias ( 'install', [ prog, man_pages ] ) +""" % locals()) + + +test.run(arguments='--install-sandbox=blubb install', stderr = None) + +test.must_exist( src_rpm ) +test.must_exist( machine_rpm ) + +test.pass_test() diff --git a/test/packaging/rpm/package.py b/test/packaging/rpm/package.py new file mode 100644 index 0000000..a5f9f0f --- /dev/null +++ b/test/packaging/rpm/package.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the ability to create a really simple rpm package. +""" + +import os +import TestSCons + +machine = TestSCons.machine +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +scons = test.program + +rpm = test.Environment().WhereIs('rpm') + +if not rpm: + test.skip_test('rpm not found, skipping test\n') + +test.subdir('src') + +test.write( [ 'src', 'main.c' ], r""" +int main( int argc, char* argv[] ) +{ + return 0; +} +""") + +test.write('SConstruct', """ +import os + +env=Environment(tools=['default', 'packaging']) + +env.Prepend(RPM = 'TAR_OPTIONS=--wildcards ') + +prog = env.Install( '/bin/' , Program( 'src/main.c') ) + +env.Package( NAME = 'foo', + VERSION = '1.2.3', + PACKAGEVERSION = 0, + PACKAGETYPE = 'rpm', + LICENSE = 'gpl', + SUMMARY = 'balalalalal', + X_RPM_GROUP = 'Application/fu', + X_RPM_INSTALL = r'%(_python_)s %(scons)s --debug=tree --install-sandbox="$RPM_BUILD_ROOT" "$RPM_BUILD_ROOT"', + DESCRIPTION = 'this should be really really long', + source = [ prog ], + SOURCE_URL = 'http://foo.org/foo-1.2.3.tar.gz' + ) + +env.Alias( 'install', prog ) +""" % locals()) + +test.run(arguments='', stderr = None) + +src_rpm = 'foo-1.2.3-0.src.rpm' +machine_rpm = 'foo-1.2.3-0.%s.rpm' % machine + +test.must_exist( machine_rpm ) +test.must_exist( src_rpm ) +test.must_not_exist( 'bin/main' ) +test.fail_test( not os.popen('rpm -qpl %s' % machine_rpm).read()=='/bin/main\n') +test.fail_test( not os.popen('rpm -qpl %s' % src_rpm).read()=='foo-1.2.3.spec\nfoo-1.2.3.tar.gz\n') + +test.pass_test() diff --git a/test/packaging/rpm/tagging.py b/test/packaging/rpm/tagging.py new file mode 100644 index 0000000..198799a --- /dev/null +++ b/test/packaging/rpm/tagging.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the ability to add file tags +""" + +import os +import string + +import TestSCons + +machine = TestSCons.machine +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +scons = test.program + +rpm = test.Environment().WhereIs('rpm') + +if not rpm: + test.skip_test('rpm not found, skipping test\n') + +# +# Test adding an attr tag to the built program. +# +test.subdir('src') + +test.write( [ 'src', 'main.c' ], r""" +int main( int argc, char* argv[] ) +{ +return 0; +} +""") + +test.write('SConstruct', """ +import os + +env = Environment(tools=['default', 'packaging']) +env.Prepend(RPM = 'TAR_OPTIONS=--wildcards ') +install_dir= os.path.join( ARGUMENTS.get('prefix', '/'), 'bin/' ) +prog_install = env.Install( install_dir , Program( 'src/main.c' ) ) +env.Tag( prog_install, UNIX_ATTR = '(0755, root, users)' ) +env.Alias( 'install', prog_install ) + +env.Package( NAME = 'foo', + VERSION = '1.2.3', + PACKAGETYPE = 'rpm', + LICENSE = 'gpl', + SUMMARY = 'balalalalal', + PACKAGEVERSION = 0, + X_RPM_GROUP = 'Applicatio/fu', + X_RPM_INSTALL = r'%(_python_)s %(scons)s --install-sandbox="$RPM_BUILD_ROOT" "$RPM_BUILD_ROOT"', + DESCRIPTION = 'this should be really really long', + source = [ prog_install ], + SOURCE_URL = 'http://foo.org/foo-1.2.3.tar.gz' + ) +""" % locals()) + +test.run(arguments='', stderr = None) + +src_rpm = 'foo-1.2.3-0.src.rpm' +machine_rpm = 'foo-1.2.3-0.%s.rpm' % machine + +test.must_exist( machine_rpm ) +test.must_exist( src_rpm ) +test.fail_test( not os.popen('rpm -qpl %s' % machine_rpm).read()=='/bin/main\n') +test.fail_test( not os.popen('rpm -qpl %s' % src_rpm).read()=='foo-1.2.3.spec\nfoo-1.2.3.tar.gz\n') + +expect = '(0755, root, users) /bin/main' +test.fail_test(string.find(test.read('foo-1.2.3.spec'), expect) == -1) + +test.pass_test() diff --git a/test/packaging/sandbox-test.py b/test/packaging/sandbox-test.py new file mode 100644 index 0000000..f82940b --- /dev/null +++ b/test/packaging/sandbox-test.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test a simple project +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +tar = test.detect('TAR', 'tar') + +if not tar: + test.skip_test('tar not found, skipping test\n') + +test.subdir('src') + +test.write([ 'src', 'foobar.h' ], '') +test.write([ 'src', 'foobar.c' ], '') + +test.write('SConstruct', """ +from glob import glob + +src_files = glob( 'src/*.c' ) +include_files = glob( 'src/*.h' ) + +SharedLibrary( 'foobar', src_files ) + +env = Environment(tools=['default', 'packaging']) + +env.Package( NAME = 'libfoobar', + VERSION = '1.2.3', + PACKAGETYPE = 'targz', + source = src_files + include_files ) + +env.Package( NAME = 'libfoobar', + VERSION = '1.2.3', + PACKAGETYPE = 'zip', + source = src_files + include_files ) +""") + +test.run(stderr=None) + +test.must_exist( 'libfoobar-1.2.3.tar.gz' ) +test.must_exist( 'libfoobar-1.2.3.zip' ) + +test.pass_test() diff --git a/test/packaging/strip-install-dir.py b/test/packaging/strip-install-dir.py new file mode 100644 index 0000000..65b6a61 --- /dev/null +++ b/test/packaging/strip-install-dir.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test stripping the InstallBuilder of the Package source file. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +test.write( 'main.c', '' ) +test.write('SConstruct', """ +prog = Install( '/bin', 'main.c' ) +env=Environment(tools=['default', 'packaging']) +env.Package( NAME = 'foo', + VERSION = '1.2.3', + source = [ prog ], + ) +""") + +expected = """scons: Reading SConscript files ... +scons: done reading SConscript files. +scons: Building targets ... +Copy file(s): "main.c" to "foo-1.2.3/bin/main.c" +tar -zc -f foo-1.2.3.tar.gz foo-1.2.3/bin/main.c +scons: done building targets. +""" + +test.run(arguments='', stderr = None, stdout=expected) + +test.must_not_exist( 'bin/main.c' ) +test.must_not_exist( '/bin/main.c' ) + +test.pass_test() diff --git a/test/packaging/tar/bz2.py b/test/packaging/tar/bz2.py new file mode 100644 index 0000000..938ac11 --- /dev/null +++ b/test/packaging/tar/bz2.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +This tests the SRC bz2 packager, which does the following: + - create a tar package from the specified files +""" + +import os +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +tar = test.detect('TAR', 'tar') + +if tar: + test.subdir('src') + + test.write( [ 'src', 'main.c' ], r""" +int main( int argc, char* argv[] ) +{ + return 0; +} + """) + + test.write('SConstruct', """ +Program( 'src/main.c' ) +env=Environment(tools=['default', 'packaging']) +env.Package( PACKAGETYPE = 'src_tarbz2', + target = 'src.tar.bz2', + PACKAGEROOT = 'test', + source = [ 'src/main.c', 'SConstruct' ] ) +""") + + test.run(arguments='', stderr = None) + + test.must_exist( 'src.tar.bz2' ) + +test.pass_test() diff --git a/test/packaging/tar/gz.py b/test/packaging/tar/gz.py new file mode 100644 index 0000000..26ce60d --- /dev/null +++ b/test/packaging/tar/gz.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +This tests the SRC 'targz' packager, which does the following: + - create a targz package containing the specified files. +""" + +import os +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +tar = test.detect('TAR', 'tar') + +if tar: + test.subdir('src') + + test.write( [ 'src', 'main.c' ], r""" +int main( int argc, char* argv[] ) +{ + return 0; +} + """) + + test.write('SConstruct', """ +Program( 'src/main.c' ) +env=Environment(tools=['default', 'packaging']) +env.Package( PACKAGETYPE = 'src_targz', + target = 'src.tar.gz', + PACKAGEROOT = 'test', + source = [ 'src/main.c', 'SConstruct' ] ) +""") + + test.run(arguments='', stderr = None) + + test.must_exist( 'src.tar.gz' ) + +test.pass_test() diff --git a/test/packaging/use-builddir.py b/test/packaging/use-builddir.py new file mode 100644 index 0000000..50a569a --- /dev/null +++ b/test/packaging/use-builddir.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the ability to use the archiver in combination with builddir. +""" + +import os +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +tar = test.detect('TAR', 'tar') + +if not tar: + test.skip_test('tar not found, skipping test\n') + +# +# TEST: builddir usage. +# +test.subdir('src') +test.subdir('build') + +test.write('src/main.c', '') + +test.write('SConstruct', """ +BuildDir('build', 'src') +env=Environment(tools=['default', 'packaging']) +env.Package( NAME = 'libfoo', + PACKAGEROOT = 'build/libfoo', + VERSION = '1.2.3', + PACKAGETYPE = 'src_zip', + target = 'build/libfoo-1.2.3.zip', + source = [ 'src/main.c', 'SConstruct' ] ) +""") + +test.run(stderr = None) + +test.must_exist( 'build/libfoo-1.2.3.zip' ) + +# TEST: builddir not placed in archive +# XXX: BuildDir should be stripped. +# +test.subdir('src') +test.subdir('build') +test.subdir('temp') + +test.write('src/main.c', '') + +test.write('SConstruct', """ +BuildDir('build', 'src') +env=Environment(tools=['default', 'packaging']) +env.Package( NAME = 'libfoo', + VERSION = '1.2.3', + PAKCAGETYPE = 'src_targz', + source = [ 'src/main.c', 'SConstruct' ] ) +""") + +test.run(stderr = None) + +test.must_exist( 'libfoo-1.2.3.tar.gz' ) + +os.popen( 'tar -C temp -xzf %s'%test.workpath('libfoo-1.2.3.tar.gz') ) + +test.must_exist( 'temp/libfoo-1.2.3/src/main.c' ) +test.must_exist( 'temp/libfoo-1.2.3/SConstruct' ) + +test.pass_test() diff --git a/test/packaging/zip.py b/test/packaging/zip.py new file mode 100644 index 0000000..a2406e6 --- /dev/null +++ b/test/packaging/zip.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +This tests the SRC zip packager, which does the following: + - create a zip package from the specified files +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +zip = test.detect('ZIP', 'zip') + +if not zip: + test.skip_test('zip not found, skipping test\n') + +test.subdir('src') + +test.write( [ 'src', 'main.c' ], r""" +int main( int argc, char* argv[] ) +{ + return 0; +} +""") + +test.write('SConstruct', """ +Program( 'src/main.c' ) +env=Environment(tools=['default', 'packaging']) +env.Package( PACKAGETYPE = 'src_zip', + target = 'src.zip', + PACKAGEROOT = 'test', + source = [ 'src/main.c', 'SConstruct' ] ) +""") + +test.run(arguments='', stderr = None) + +test.must_exist( 'src.zip' ) + +test.pass_test() |