def test_build(self):
        self.useFixture(tests.fixture_setup.CleanEnvironment())
        self.useFixture(fixtures.EnvironmentVariable('PATH', '/bin'))

        class Options:
            source = '.'
            gulp_tasks = []
            node_engine = '4'

        plugin = gulp.GulpPlugin('test-part', Options(), self.project_options)

        os.makedirs(plugin.sourcedir)
        open(os.path.join(plugin.sourcedir, 'package.json'), 'w').close()

        plugin.build()

        path = '{}:/bin'.format(os.path.join(plugin._npm_dir, 'bin'))
        self.run_mock.assert_has_calls([
            mock.call(['npm', 'install', '-g', 'gulp-cli'],
                      cwd=plugin.builddir,
                      env={'PATH': path}),
            mock.call(['npm', 'install', '--only-development'],
                      cwd=plugin.builddir,
                      env={'PATH': path}),
        ])

        self.tar_mock.assert_has_calls([
            mock.call(nodejs.get_nodejs_release(plugin.options.node_engine),
                      os.path.join(plugin._npm_dir)),
            mock.call().provision(plugin._npm_dir,
                                  clean_target=False,
                                  keep_tarball=True)
        ])
Esempio n. 2
0
    def test_unsupported_arch_raises_exception(self, machine_mock):
        machine_mock.return_value = 'fantasy-arch'

        class Options:
            source = None
            gulp_tasks = []
            node_engine = '4'

        with self.assertRaises(EnvironmentError) as raised:
            gulp.GulpPlugin('test-part', Options(), self.project_options)

        self.assertEqual(raised.exception.__str__(),
                         'architecture not supported (fantasy-arch)')
Esempio n. 3
0
    def test_build(self, platform_machine_mock, platform_architecture_mock):
        self.useFixture(fixture_setup.CleanEnvironment())
        self.useFixture(fixtures.EnvironmentVariable("PATH", "/bin"))

        class Options:
            source = "."
            gulp_tasks = []
            node_engine = "4"

        platform_machine_mock.return_value = "x86_64"
        platform_architecture_mock.return_value = ("64bit", "ELF")
        plugin = gulp.GulpPlugin("test-part", Options(), self.project_options)

        os.makedirs(plugin.builddir)
        open(os.path.join(plugin.builddir, "package.json"), "w").close()

        plugin.build()

        path = "{}:/bin".format(os.path.join(plugin._npm_dir, "bin"))
        self.run_mock.assert_has_calls([
            mock.call(
                ["npm", "install", "-g", "gulp-cli"],
                cwd=plugin.builddir,
                env={
                    "PATH": path,
                    "NPM_CONFIG_PREFIX": plugin._npm_dir
                },
            ),
            mock.call(
                ["npm", "install", "--only-development"],
                cwd=plugin.builddir,
                env={
                    "PATH": path,
                    "NPM_CONFIG_PREFIX": plugin._npm_dir
                },
            ),
        ])

        self.tar_mock.assert_has_calls([
            mock.call(
                nodejs.get_nodejs_release(plugin.options.node_engine,
                                          plugin.project.deb_arch),
                os.path.join(plugin._npm_dir),
            ),
            mock.call().provision(plugin._npm_dir,
                                  clean_target=False,
                                  keep_tarball=True),
        ])
Esempio n. 4
0
    def test_clean_pull_step(self):
        class Options:
            source = '.'
            gulp_tasks = []
            node_engine = '4'

        plugin = gulp.GulpPlugin('test-part', Options(), self.project_options)

        os.makedirs(plugin.sourcedir)

        plugin.pull()

        self.assertTrue(os.path.exists(plugin._npm_dir))

        plugin.clean_pull()

        self.assertFalse(os.path.exists(plugin._npm_dir))
Esempio n. 5
0
    def test_pull_local_sources(self):
        class Options:
            source = '.'
            gulp_tasks = []
            node_engine = '4'

        plugin = gulp.GulpPlugin('test-part', Options(), self.project_options)

        os.makedirs(plugin.sourcedir)

        plugin.pull()

        self.assertFalse(self.run_mock.called, 'run() was called')
        self.tar_mock.assert_has_calls([
            mock.call(
                nodejs.get_nodejs_release(plugin.options.node_engine),
                path.join(os.path.abspath('.'), 'parts', 'test-part', 'npm')),
            mock.call().download()
        ])
Esempio n. 6
0
    def test_pull_local_sources(self):
        class Options:
            source = "."
            gulp_tasks = []
            node_engine = "4"

        plugin = gulp.GulpPlugin("test-part", Options(), self.project_options)

        os.makedirs(plugin.sourcedir)

        plugin.pull()

        self.assertFalse(self.run_mock.called, "run() was called")
        self.tar_mock.assert_has_calls([
            mock.call(
                nodejs.get_nodejs_release(plugin.options.node_engine,
                                          plugin.project.deb_arch),
                path.join(self.parts_dir, "test-part", "npm"),
            ),
            mock.call().download(),
        ])