Beispiel #1
0
 def testGetBuildLocation(self):
     root = self.CreateTestPackage('foo')
     pkg = source_package.SourcePackage(root)
     location = pkg.GetBuildLocation()
     self.assertTrue(location.startswith(paths.BUILD_ROOT))
     self.assertEqual(os.path.basename(location),
                      '%s-%s' % (pkg.NAME, pkg.VERSION))
Beispiel #2
0
 def testIsBuiltMalformedBinary(self):
     """test that IsBuilt() can handle malformed package files."""
     root = self.CreateTestPackage('foo')
     pkg = source_package.SourcePackage(root)
     invalid_binary = os.path.join(self.tempdir, 'package.tar.bz2')
     with open(invalid_binary, 'w') as f:
         f.write('this is not valid package file\n')
     pkg.PackageFile = Mock(return_value=invalid_binary)
     self.assertFalse(pkg.IsBuilt())
Beispiel #3
0
    def testExtract(self):
        root = self.CreateTestPackage('foo', 'URL=someurl.tar.gz\nSHA1=123')
        pkg = source_package.SourcePackage(root)

        def fake_extract(archive, dest):
            os.mkdir(os.path.join(dest, '%s-%s' % (pkg.NAME, pkg.VERSION)))

        with patch('webports.source_package.ExtractArchive', fake_extract):
            pkg.Extract()
Beispiel #4
0
 def test_installed_info_contents(self):
     root = self.create_mock_package('foo')
     pkg = source_package.SourcePackage(root)
     expected_contents = textwrap.dedent('''\
   NAME=foo
   VERSION=1.0
   BUILD_CONFIG=release
   BUILD_ARCH=pnacl
   BUILD_TOOLCHAIN=pnacl
   BUILD_SDK_VERSION=1234
   ''')
     self.assertRegex(pkg.installed_info_contents(), expected_contents)
Beispiel #5
0
 def testInstalledInfoContents(self):
     root = self.CreateTestPackage('foo')
     pkg = source_package.SourcePackage(root)
     expected_contents = textwrap.dedent('''\
   NAME=foo
   VERSION=1.0
   BUILD_CONFIG=release
   BUILD_ARCH=pnacl
   BUILD_TOOLCHAIN=pnacl
   BUILD_SDK_VERSION=1234
   ''')
     self.assertRegexpMatches(pkg.InstalledInfoContents(),
                              expected_contents)
Beispiel #6
0
    def testConflicts(self):
        root = self.CreateTestPackage('foo', 'CONFLICTS=(bar)')
        pkg = source_package.SourcePackage(root)

        # with no other packages installed
        with patch('webports.util.IsInstalled', Mock(return_value=False)):
            pkg.CheckInstallable()

        # with all possible packages installed
        with patch('webports.util.IsInstalled') as is_installed:
            is_installed.return_value = True
            with self.assertRaises(source_package.PkgConflictError):
                pkg.CheckInstallable()
            is_installed.assert_called_once_with('bar', pkg.config)
Beispiel #7
0
 def testBuildPackage(self):
     root = self.CreateTestPackage('foo')
     pkg = source_package.SourcePackage(root)
     pkg.Build(True)
Beispiel #8
0
 def testValidSourceDir(self):
     """test that valid source directory is loaded correctly."""
     root = self.CreateTestPackage('foo')
     pkg = source_package.SourcePackage(root)
     self.assertEqual(pkg.NAME, 'foo')
     self.assertEqual(pkg.root, root)
Beispiel #9
0
 def testInvalidSourceDir(self):
     """test that invalid source directory generates an error."""
     path = '/bad/path'
     expected_error = 'Invalid package folder: ' + path
     with self.assertRaisesRegexp(error.Error, expected_error):
         source_package.SourcePackage(path)
Beispiel #10
0
 def testDisabled(self):
     root = self.CreateTestPackage('foo', 'DISABLED=1')
     pkg = source_package.SourcePackage(root)
     with self.assertRaisesRegexp(error.DisabledError,
                                  'package is disabled'):
         pkg.CheckInstallable()
Beispiel #11
0
 def testGetInstalledPackage(self):
     root = self.CreateTestPackage('foo')
     pkg = source_package.SourcePackage(root)
     with self.assertRaisesRegexp(error.Error,
                                  'package not installed: foo'):
         pkg.GetInstalledPackage()
Beispiel #12
0
 def test_build_package(self):
     root = self.create_mock_package('foo')
     pkg = source_package.SourcePackage(root)
     pkg.build(True)
Beispiel #13
0
 def test_valid_source_dir(self):
     """test that valid source directory is loaded correctly."""
     root = self.create_mock_package('foo')
     pkg = source_package.SourcePackage(root)
     self.assertEqual(pkg.NAME, 'foo')
     self.assertEqual(pkg.root, root)
Beispiel #14
0
 def test_disabled(self):
     root = self.create_mock_package('foo', 'DISABLED=1')
     pkg = source_package.SourcePackage(root)
     with self.assertRaisesRegexp(error.DisabledError,
                                  'package is disabled'):
         pkg.check_installable()
Beispiel #15
0
 def test_get_installed_package(self):
     root = self.create_mock_package('foo')
     pkg = source_package.SourcePackage(root)
     with self.assertRaisesRegexp(error.Error,
                                  'package not installed: foo'):
         pkg.get_installed_package()