Exemple #1
0
    def testCompile(self):
        compile("setup", hello_uri, self.hello_dir, expect="Created directory")
        os.chdir(self.hello_dir)

        compile("build", expect='Executing: "%s"' % os.path.join("$SRCDIR", "configure"))

        target_dir = "gnu-hello-%s" % support.get_arch_name().lower()
        archive_stem = "gnu-hello-%s-1.3" % support.get_arch_name().lower()
        assert os.path.isdir(target_dir), "%s not a directory" % target_dir

        run(os.path.join(target_dir, "bin", "hello"), expect="Hello, world!")
        run(launch_command, os.path.join(target_dir, "0install", "feed.xml"), expect="Hello, world!")
        compile("publish", "http://localhost/downloads", expect="Now upload '%s.tar.bz2'" % archive_stem)
Exemple #2
0
    def testCompile(self):
        compile('setup', hello_uri, self.hello_dir, expect='Created directory')
        os.chdir(self.hello_dir)

        compile('build',
                expect='Executing: "%s"' %
                os.path.join('$SRCDIR', 'configure'))

        target_dir = 'gnu-hello-%s' % support.get_arch_name().lower()
        archive_stem = 'gnu-hello-%s-1.3' % support.get_arch_name().lower()
        assert os.path.isdir(target_dir), '%s not a directory' % target_dir

        run(os.path.join(target_dir, 'bin', 'hello'), expect='Hello, world!')
        run(zi_command,
            "run",
            os.path.join(target_dir, '0install', 'feed.xml'),
            expect='Hello, world!')
        compile('publish',
                'http://localhost/downloads',
                expect="Now upload '%s.tar.bz2'" % archive_stem)
Exemple #3
0
    def testCopySrc(self):
        comp_dir = os.path.join(self.tmpdir, "cprog")
        compile("setup", local_cprog_path, comp_dir, expect="Created directory")
        os.chdir(comp_dir)
        compile("diff", expect="No local src directory to diff against", expect_status=1)
        compile("diff", "foo", expect="usage", expect_status=1)
        compile("copy-src", "foo", expect="usage", expect_status=1)
        compile("copy-src", expect="Copied as")
        compile("copy-src", expect="Directory '", expect_status=1)

        # 'src' exists, but no changes
        compile("diff")
        compile("--verbose", "build", expect="Hello from C")
        target_dir = "cprog-%s" % support.get_arch_name().lower()
        patch_file = os.path.join(target_dir, "0install", "from-0.1.patch")
        assert not os.path.exists(patch_file)

        # 'src' contains a change
        prog = file(os.path.join("src", "main.c")).read()
        prog = prog.replace("Hello", "Goodbye")
        stream = file(os.path.join("src", "main.c"), "w")
        stream.write(prog)
        stream.close()
        compile("diff", expect="diff")
        shutil.rmtree("build")
        compile("build", expect="Goodbye from C")
        assert os.path.exists(patch_file)

        # Test dup-src's unlinking while we're here
        compile("build", expect="Goodbye from C")

        # 'src' contains an error
        stream = file(os.path.join("src", "main.c"), "w")
        stream.write("this is not valid C!")
        stream.close()
        shutil.rmtree("build")
        compile("build", expect="Build failed", expect_status=1)
        assert os.path.exists(os.path.join("build", "build-failure.log"))

        # 'src' does not exist
        shutil.rmtree("src")
        shutil.rmtree("build")
        compile("build", expect="Hello from C")
        assert not os.path.exists(patch_file)

        # Check we fixed the .pc files...
        pc_data = open(os.path.join(target_dir, "pkgconfig", "cprog.pc")).read()
        assert pc_data == "prefix=" + os.path.join("${pcfiledir}", os.path.pardir) + "\n", ` pc_data `

        # Check we removed the bad .la files...
        assert not os.path.exists(os.path.join(target_dir, "lib", "bad.la"))  # libtool - bad
        assert os.path.exists(os.path.join(target_dir, "lib", "good.la"))  # Ends in .la, but not a libtool archive
        assert os.path.exists(os.path.join(target_dir, "lib", "nice.ok"))  # Doesn't end in .la
Exemple #4
0
 def testCommand(self):
     comp_dir = os.path.join(self.tmpdir, "cprog-command")
     compile("setup", local_cprog_command_path, comp_dir, expect="Created directory")
     os.chdir(comp_dir)
     compile("build", expect="Hello from C!")
     target_dir = "cprog-command-%s" % support.get_arch_name().lower()
     binary_feed = os.path.join(target_dir, "0install", "feed.xml")
     run(launch_command, binary_feed, expect="Hello from C!")
     s = open(binary_feed, "r")
     feed = model.ZeroInstallFeed(qdom.parse(s), binary_feed)
     s.close()
     impl, = feed.implementations.values()
     assert impl.arch, "Missing arch on %s" % impl
Exemple #5
0
 def testCommand(self):
     comp_dir = os.path.join(self.tmpdir, 'cprog-command')
     compile('setup',
             local_cprog_command_path,
             comp_dir,
             expect='Created directory')
     os.chdir(comp_dir)
     compile('build', expect='Hello from C!')
     target_dir = 'cprog-command-%s' % support.get_arch_name().lower()
     binary_feed = os.path.join(target_dir, '0install', 'feed.xml')
     run(zi_command, "run", binary_feed, expect='Hello from C!')
     s = open(binary_feed, 'r')
     feed = model.ZeroInstallFeed(qdom.parse(s), binary_feed)
     s.close()
     impl, = feed.implementations.values()
     assert impl.arch, "Missing arch on %s" % impl
     self.assertEqual("Public Domain", str(impl.metadata['license']))
Exemple #6
0
    def testCopySrc(self):
        comp_dir = os.path.join(self.tmpdir, 'cprog')
        compile('setup',
                local_cprog_path,
                comp_dir,
                expect='Created directory')
        os.chdir(comp_dir)
        compile('diff',
                expect="No local src directory to diff against",
                expect_status=1)
        compile('diff', 'foo', expect='usage', expect_status=1)
        compile('copy-src', 'foo', expect='usage', expect_status=1)
        compile('copy-src', expect='Copied as')
        compile('copy-src', expect="Directory '", expect_status=1)

        # 'src' exists, but no changes
        compile('diff')
        compile('--verbose', 'build', expect='Hello from C')
        target_dir = 'cprog-%s' % support.get_arch_name().lower()
        patch_file = os.path.join(target_dir, '0install', 'from-0.1.patch')
        assert not os.path.exists(patch_file)

        # 'src' contains a change
        prog = file(os.path.join('src', 'main.c')).read()
        prog = prog.replace('Hello', 'Goodbye')
        stream = file(os.path.join('src', 'main.c'), 'w')
        stream.write(prog)
        stream.close()
        compile('diff', expect='diff')
        shutil.rmtree('build')
        compile('build', expect='Goodbye from C')
        assert os.path.exists(patch_file)

        # Test dup-src's unlinking while we're here
        compile('build', expect='Goodbye from C')

        # 'src' contains an error
        stream = file(os.path.join('src', 'main.c'), 'w')
        stream.write('this is not valid C!')
        stream.close()
        shutil.rmtree('build')
        compile('build', expect='Build failed', expect_status=1)
        assert os.path.exists(os.path.join('build', 'build-failure.log'))

        # 'src' does not exist
        shutil.rmtree('src')
        shutil.rmtree('build')
        compile('build', expect='Hello from C')
        assert not os.path.exists(patch_file)

        # Check we fixed the .pc files...
        pc_data = open(os.path.join(target_dir, 'pkgconfig',
                                    'cprog.pc')).read()
        assert pc_data == "prefix=" + os.path.join(
            "${pcfiledir}", os.path.pardir) + "\n", ` pc_data `

        # Check we removed the bad .la files...
        assert not os.path.exists(os.path.join(target_dir, 'lib',
                                               'bad.la'))  # libtool - bad
        assert os.path.exists(
            os.path.join(target_dir, 'lib',
                         'good.la'))  # Ends in .la, but not a libtool archive
        assert os.path.exists(os.path.join(target_dir, 'lib',
                                           'nice.ok'))  # Doesn't end in .la