Exemple #1
0
    def test_prepare_base(self):
        basedir = utils.mkdtemp(self)
        export_target = join(basedir, 'artifacts', 'export.js')
        with pretty_logging(stream=mocks.StringIO()) as s:
            self.assertTrue(prepare_export_location(export_target))

        self.assertTrue(exists(join(basedir, 'artifacts')))
        self.assertIn("artifacts", s.getvalue())
Exemple #2
0
    def test_prepare_base(self):
        basedir = utils.mkdtemp(self)
        export_target = join(basedir, 'artifacts', 'export.js')
        with pretty_logging(stream=mocks.StringIO()) as s:
            self.assertTrue(prepare_export_location(export_target))

        self.assertTrue(exists(join(basedir, 'artifacts')))
        self.assertIn("artifacts", s.getvalue())
Exemple #3
0
    def test_prepare_existed_dir_removed(self):
        basedir = utils.mkdtemp(self)
        export_target = join(basedir, 'export.js')
        os.mkdir(export_target)

        with pretty_logging(stream=mocks.StringIO()) as s:
            self.assertTrue(prepare_export_location(export_target))

        self.assertIn(
            "removing existing export target directory at '%s'" %
            export_target, s.getvalue())
        self.assertFalse(exists(export_target))
Exemple #4
0
    def test_prepare_base_parent_is_file(self):
        basedir = utils.mkdtemp(self)
        export_target = join(basedir, 'artifacts', 'export.js')
        with open(join(basedir, 'artifacts'), 'w'):
            pass

        with self.assertRaises(ToolchainAbort):
            with pretty_logging(stream=mocks.StringIO()) as s:
                self.assertFalse(prepare_export_location(export_target))

        self.assertIn("cannot export to '%s'" % export_target, s.getvalue())
        self.assertTrue(isfile(join(basedir, 'artifacts')))
Exemple #5
0
    def test_prepare_existed_dir_removed(self):
        basedir = utils.mkdtemp(self)
        export_target = join(basedir, 'export.js')
        os.mkdir(export_target)

        with pretty_logging(stream=mocks.StringIO()) as s:
            self.assertTrue(prepare_export_location(export_target))

        self.assertIn(
            "removing existing export target directory at '%s'" %
            export_target, s.getvalue())
        self.assertFalse(exists(export_target))
Exemple #6
0
    def test_prepare_base_parent_is_file(self):
        basedir = utils.mkdtemp(self)
        export_target = join(basedir, 'artifacts', 'export.js')
        with open(join(basedir, 'artifacts'), 'w'):
            pass

        with self.assertRaises(ToolchainAbort):
            with pretty_logging(stream=mocks.StringIO()) as s:
                self.assertFalse(prepare_export_location(export_target))

        self.assertIn("cannot export to '%s'" % export_target, s.getvalue())
        self.assertTrue(isfile(join(basedir, 'artifacts')))
Exemple #7
0
    def test_prepare_existed_dir_collision(self):
        basedir = utils.mkdtemp(self)
        conflict = join(basedir, 'some')
        export_target = join(conflict, 'target', 'export.js')
        with open(conflict, 'w'):
            pass

        with self.assertRaises(ToolchainAbort):
            with pretty_logging(stream=mocks.StringIO()) as s:
                self.assertFalse(prepare_export_location(export_target))

        self.assertIn("failed to prepare export location", s.getvalue())
        self.assertFalse(exists(export_target))
Exemple #8
0
    def test_prepare_existed_dir_collision(self):
        basedir = utils.mkdtemp(self)
        conflict = join(basedir, 'some')
        export_target = join(conflict, 'target', 'export.js')
        with open(conflict, 'w'):
            pass

        with self.assertRaises(ToolchainAbort):
            with pretty_logging(stream=mocks.StringIO()) as s:
                self.assertFalse(prepare_export_location(export_target))

        self.assertIn("failed to prepare export location", s.getvalue())
        self.assertFalse(exists(export_target))
Exemple #9
0
 def check_target(export_target):
     # manually create the root here, to allow the completion
     # of the build process by doing what an existing
     # implementation that reuse existing code might have done.
     targets.append(export_target)
     prepare_export_location(export_target)
Exemple #10
0
 def check_target(export_target):
     # manually create the root here, to allow the completion
     # of the build process by doing what an existing
     # implementation that reuse existing code might have done.
     targets.append(export_target)
     prepare_export_location(export_target)