Exemplo n.º 1
0
 def setUp(self):
     BaseTest.setUp(self)
     os.environ["PATH"] = os.pathsep.join(
         [os.environ["PATH"],
          os.path.abspath(os.path.dirname(__file__))])
     self.tmp_file = self.get_tmp_file(4)
     self.edit_cmd = AutobuildTool()
Exemplo n.º 2
0
class TestEdit(unittest.TestCase, AutobuildBaselineCompare):
    def setUp(self):
        os.environ["PATH"] = os.pathsep.join([os.environ["PATH"], os.path.abspath(os.path.dirname(__file__))])
        self.tmp_file = self.get_tmp_file(4)
        self.edit_cmd = AutobuildTool()

    def _try_cmd(self, args):
        """
        Try running an edit 'command with args'.
        Return results.
        """
        self.edit_cmd.main(args)
        return llsd.parse(file(self.tmp_file, 'rb').read())

    def test_build(self):
        """
        Perform non-interactive configuration of build command.
        Check results.
        """
        args = ['build', "--config-file=%s" % self.tmp_file, 'name=newbuild', 'platform=windows', 'command=makethis']
        expected_config = {'package_description': {'platforms': {'windows': {'name': 'windows', 'configurations': {'newbuild': {'build': {'command': 'makethis'}, 'name': 'newbuild'}}}}}, 'version': '1.2', 'type': 'autobuild'}
        built_config = self._try_cmd(args)
        assert (expected_config == built_config)
           
    def test_configure(self):
        """
        Perform non-interactive configuration of configure command.
        Check results.
        """
        args = ['configure', "--config-file=%s" % self.tmp_file, 'name=newbuild', 'platform=windows', 'command=makethat']
        expected_config = {'package_description': {'platforms': {'windows': {'name': 'windows', 'configurations': {'newbuild': {'configure': {'command': 'makethat'}, 'name': 'newbuild'}}}}}, 'version': '1.2', 'type': 'autobuild'}
        built_config = self._try_cmd(args)
        assert (expected_config == built_config)

    def test_build_configure(self):
        """
        Perform two updates to the config file in series. 
        Check results after each iteration.
        """
        args = ['configure', "--config-file=%s" % self.tmp_file, 'name=newbuild', 'platform=windows', 'command=makethat']
        built_config1 = self._try_cmd(args)
        expected_config1 = {'package_description': {'platforms': {'windows': {'name': 'windows', 'configurations': {'newbuild': {'configure': {'command': 'makethat'}, 'name': 'newbuild'}}}}}, 'version': '1.2', 'type': 'autobuild'}
        assert (expected_config1 == built_config1)
        args = ['build', "--config-file=%s" % self.tmp_file, 'name=newbuild', 'platform=windows', 'command=makethis']
        built_config2 = self._try_cmd(args)
        expected_config2 = {'package_description': {'platforms': {'windows': {'name': 'windows', 'configurations': {'newbuild': {'build': {'command': 'makethis'}, 'name': 'newbuild', 'configure': {'command': 'makethat'}}}}}}, 'version': '1.2', 'type': 'autobuild'}
        assert (expected_config2 == built_config2)
        
    def test_platform_configure(self):
        args = ['platform', "--config-file=%s" % self.tmp_file, 'name=windows', 'build_directory=foo/bar/baz']
        built_config = self._try_cmd(args)
        assert built_config['package_description']['platforms']['windows']['build_directory'] == 'foo/bar/baz'

    def tearDown(self):
        self.cleanup_tmp_file()
Exemplo n.º 3
0
 def setUp(self):
     os.environ["PATH"] = os.pathsep.join([os.environ["PATH"], os.path.abspath(os.path.dirname(__file__))])
     self.tmp_file = self.get_tmp_file(4)
     self.edit_cmd = AutobuildTool()
Exemplo n.º 4
0
class TestEdit(BaseTest, AutobuildBaselineCompare):
    def setUp(self):
        BaseTest.setUp(self)
        os.environ["PATH"] = os.pathsep.join(
            [os.environ["PATH"],
             os.path.abspath(os.path.dirname(__file__))])
        self.tmp_file = self.get_tmp_file(4)
        self.edit_cmd = AutobuildTool()

    def _try_cmd(self, args):
        """
        Try running an edit 'command with args'.
        Return results.
        """
        self.edit_cmd.main(args)
        return llsd.parse(file(self.tmp_file, 'rb').read())

    def test_build(self):
        """
        Perform non-interactive configuration of build command.
        Check results.
        """
        args = [
            'build',
            "--config-file=%s" % self.tmp_file, 'name=newbuild',
            'platform=windows', 'command=makethis'
        ]
        expected_config = {
            'package_description': {
                'platforms': {
                    'windows': {
                        'name': 'windows',
                        'configurations': {
                            'newbuild': {
                                'build': {
                                    'command': 'makethis'
                                },
                                'name': 'newbuild'
                            }
                        }
                    }
                }
            },
            'version': configfile.AUTOBUILD_CONFIG_VERSION,
            'type': 'autobuild'
        }
        built_config = self._try_cmd(args)
        assert_equals(expected_config, built_config)

    def test_configure(self):
        """
        Perform non-interactive configuration of configure command.
        Check results.
        """
        args = [
            'configure',
            "--config-file=%s" % self.tmp_file, 'name=newbuild',
            'platform=windows', 'command=makethat'
        ]
        expected_config = {
            'package_description': {
                'platforms': {
                    'windows': {
                        'name': 'windows',
                        'configurations': {
                            'newbuild': {
                                'configure': {
                                    'command': 'makethat'
                                },
                                'name': 'newbuild'
                            }
                        }
                    }
                }
            },
            'version': configfile.AUTOBUILD_CONFIG_VERSION,
            'type': 'autobuild'
        }
        built_config = self._try_cmd(args)
        assert_equals(expected_config, built_config)

    def test_build_configure(self):
        """
        Perform two updates to the config file in series. 
        Check results after each iteration.
        """
        args = [
            'configure',
            "--config-file=%s" % self.tmp_file, 'name=newbuild',
            'platform=windows', 'command=makethat'
        ]
        built_config1 = self._try_cmd(args)
        expected_config1 = {
            'package_description': {
                'platforms': {
                    'windows': {
                        'name': 'windows',
                        'configurations': {
                            'newbuild': {
                                'configure': {
                                    'command': 'makethat'
                                },
                                'name': 'newbuild'
                            }
                        }
                    }
                }
            },
            'version': configfile.AUTOBUILD_CONFIG_VERSION,
            'type': 'autobuild'
        }
        assert_equals(expected_config1, built_config1)
        args = [
            'build',
            "--config-file=%s" % self.tmp_file, 'name=newbuild',
            'platform=windows', 'command=makethis'
        ]
        built_config2 = self._try_cmd(args)
        expected_config2 = {
            'package_description': {
                'platforms': {
                    'windows': {
                        'name': 'windows',
                        'configurations': {
                            'newbuild': {
                                'build': {
                                    'command': 'makethis'
                                },
                                'name': 'newbuild',
                                'configure': {
                                    'command': 'makethat'
                                }
                            }
                        }
                    }
                }
            },
            'version': configfile.AUTOBUILD_CONFIG_VERSION,
            'type': 'autobuild'
        }
        assert_equals(expected_config2, built_config2)

    def test_platform_configure(self):
        args = [
            'platform',
            "--config-file=%s" % self.tmp_file, 'name=windows',
            'build_directory=foo/bar/baz'
        ]
        built_config = self._try_cmd(args)
        assert_equals(
            built_config['package_description']['platforms']['windows']
            ['build_directory'], 'foo/bar/baz')

    def tearDown(self):
        self.cleanup_tmp_file()
        BaseTest.tearDown(self)