コード例 #1
0
ファイル: make_rpm_test.py プロジェクト: bazelbuild/rules_pkg
    def testSetupWorkdir(self):
        with make_rpm.Tempdir() as outer:
            dummy = os.sep.join([outer, 'rpmbuild'])
            WriteFile(dummy, 'dummy rpmbuild')
            os.chmod(dummy, 0o777)

            with PrependPath([outer]):
                # Create the builder and exercise it.
                builder = make_rpm.RpmBuilder('test', '1.0', '0', 'x86', None)

                # Create spec_file, test files.
                WriteFile('test.spec', 'Name: test', 'Version: 0.1',
                          'Summary: test data')
                WriteFile('file1.txt', 'Hello')
                WriteFile('file2.txt', 'Goodbye')
                builder.AddFiles(['file1.txt', 'file2.txt'])

                with make_rpm.Tempdir():
                    # Call RpmBuilder.
                    builder.SetupWorkdir('test.spec', outer)

                    # Make sure files exist.
                    self.assertTrue(DirExists('SOURCES'))
                    self.assertTrue(DirExists('BUILD'))
                    self.assertTrue(DirExists('TMP'))
                    self.assertTrue(FileExists('test.spec'))
                    self.assertCountEqual(
                        ['Name: test', 'Version: 1.0', 'Summary: test data'],
                        FileContents('test.spec'))
                    self.assertTrue(FileExists('BUILD/file1.txt'))
                    self.assertCountEqual(['Hello'],
                                          FileContents('BUILD/file1.txt'))
                    self.assertTrue(FileExists('BUILD/file2.txt'))
                    self.assertCountEqual(['Goodbye'],
                                          FileContents('BUILD/file2.txt'))
コード例 #2
0
ファイル: make_rpm_test.py プロジェクト: bazelbuild/rules_pkg
    def testBuild(self):
        with make_rpm.Tempdir() as outer:
            dummy = os.sep.join([outer, 'rpmbuild'])
            WriteFile(
                dummy,
                '#!/bin/sh',
                'mkdir -p RPMS',
                'touch RPMS/test.rpm',
                'echo "Wrote: $PWD/RPMS/test.rpm"',
            )
            os.chmod(dummy, 0o777)

            with PrependPath([outer]):
                # Create the builder and exercise it.
                builder = make_rpm.RpmBuilder('test', '1.0', '0', 'x86', None)

                # Create spec_file, test files.
                WriteFile('test.spec', 'Name: test', 'Version: 0.1',
                          'Summary: test data')

                # Call RpmBuilder.
                builder.Build('test.spec', 'test.rpm')

                # Make sure files exist.
                self.assertTrue(FileExists('test.rpm'))
コード例 #3
0
ファイル: make_rpm_test.py プロジェクト: bazelbuild/rules_pkg
 def testFindRpmbuild_missing(self):
     with make_rpm.Tempdir() as outer:
         with ReplacePath([outer]):
             with self.assertRaises(
                     make_rpm.NoRpmbuildFoundError) as context:
                 make_rpm.FindRpmbuild('')
             self.assertIsNotNone(context)
コード例 #4
0
ファイル: make_rpm_test.py プロジェクト: bazelbuild/rules_pkg
 def testFindRpmbuild_present(self):
     with make_rpm.Tempdir() as outer:
         dummy = os.sep.join([outer, 'rpmbuild'])
         WriteFile(dummy, 'dummy rpmbuild')
         os.chmod(dummy, 0o777)
         with PrependPath([outer]):
             path = make_rpm.FindRpmbuild('')
             self.assertEqual(dummy, path)
コード例 #5
0
ファイル: make_rpm_test.py プロジェクト: bazelbuild/rules_pkg
    def testCopyAndRewrite(self):
        with make_rpm.Tempdir():
            WriteFile('test.txt', 'Some: data1', 'Other: data2', 'More: data3')
            make_rpm.CopyAndRewrite('test.txt', 'out.txt', {
                'Some:': 'data1a',
                'More:': 'data3a',
            })

            self.assertTrue(FileExists('out.txt'))
            self.assertCountEqual(
                ['Some: data1a', 'Other: data2', 'More: data3a'],
                FileContents('out.txt'))