def build_xpi_test(self, modules): " prepare and build XPI for test only (unsaved modules) " if self.package.type == 'l': raise Exception('only Add-ons may build a XPI') sdk_dir = self.get_sdk_dir() # TODO: consider SDK staying per PackageRevision... if os.path.isdir(sdk_dir): xpi_remove(sdk_dir) sdk_copy(sdk_dir) self.export_keys(sdk_dir) packages_dir = '%s/packages' % sdk_dir package_dir = self.package.make_dir(packages_dir) self.export_manifest(package_dir) # instead of export modules lib_dir = '%s/%s' % (package_dir, self.package.get_lib_dir()) for mod in self.modules.all(): mod_edited = False for e_mod in modules: if e_mod.pk == mod.pk: mod_edited = True e_mod.export_code(lib_dir) if not mod_edited: mod.export_code(lib_dir) self.export_attachments('%s/%s' % (package_dir, self.package.get_data_dir())) self.export_dependencies(packages_dir) return (xpi_build(sdk_dir, '%s/packages/%s' % (sdk_dir, self.package.get_unique_package_name())) )
def build_xpi_test(self, modules): " prepare and build XPI for test only (unsaved modules) " if self.package.type == "l": raise Exception("only Add-ons may build a XPI") sdk_dir = self.get_sdk_dir() sdk_source = self.sdk.get_source_dir() # This SDK is always different! - working on unsaved data if os.path.isdir(sdk_dir): xpi_remove(sdk_dir) sdk_copy(sdk_source, sdk_dir) self.export_keys(sdk_dir) packages_dir = "%s/packages" % sdk_dir package_dir = self.package.make_dir(packages_dir) self.export_manifest(package_dir) # instead of export modules lib_dir = "%s/%s" % (package_dir, self.package.get_lib_dir()) for mod in self.modules.all(): mod_edited = False for e_mod in modules: if e_mod.pk == mod.pk: mod_edited = True e_mod.export_code(lib_dir) if not mod_edited: mod.export_code(lib_dir) self.export_attachments("%s/%s" % (package_dir, self.package.get_data_dir())) self.export_dependencies(packages_dir) return xpi_build(sdk_dir, "%s/packages/%s" % (sdk_dir, self.package.get_unique_package_name()))
def test_minimal_xpi_creation(self): " xpi build from an addon straight after creation " sdk_copy(SDKDIR) self.addonrev.export_files_with_dependencies('%s/packages' % SDKDIR) out = xpi_build(SDKDIR, '%s/packages/%s' % (SDKDIR, self.addon.get_unique_package_name())) # assert no error output self.assertEqual('', out[1]) # assert xpi was created self.failUnless(os.path.isfile('%s/packages/%s/%s.xpi' % ( SDKDIR, self.addon.get_unique_package_name(), self.addon.name)))
def test_xpi_with_dependency(self): " addon has one dependency with a file " self.addonrev.dependency_add(self.librev) sdk_copy(SDKDIR) self.addonrev.export_files_with_dependencies('%s/packages' % SDKDIR) out = xpi_build(SDKDIR, '%s/packages/%s' % (SDKDIR, self.addon.get_unique_package_name())) # assert no error output self.assertEqual('', out[1]) # assert xpi was created self.failUnless(os.path.isfile('%s/packages/%s/%s.xpi' % ( SDKDIR, self.addon.get_unique_package_name(), self.addon.name)))
def build_xpi(self): " prepare and build XPI " if self.package.type == 'l': raise Exception('only Add-ons may build a XPI') sdk_dir = self.get_sdk_dir() # TODO: consider SDK staying per PackageRevision... if os.path.isdir(sdk_dir): xpi_remove(sdk_dir) sdk_copy(sdk_dir) self.export_keys(sdk_dir) self.export_files_with_dependencies('%s/packages' % sdk_dir) return (xpi_build(sdk_dir, '%s/packages/%s' % (sdk_dir, self.package.get_unique_package_name())) )
def test_addon_with_other_modules(self): " addon has now more modules " self.addonrev.module_create( filename=TEST_FILENAME, author=self.user ) sdk_copy(SDKDIR) self.addonrev.export_files_with_dependencies('%s/packages' % SDKDIR) out = xpi_build(SDKDIR, '%s/packages/%s' % (SDKDIR, self.addon.get_unique_package_name())) # assert no error output self.assertEqual('', out[1]) self.failUnless(out[0]) # assert xpi was created self.failUnless(os.path.isfile('%s/packages/%s/%s.xpi' % ( SDKDIR, self.addon.get_unique_package_name(), self.addon.name)))
def build_xpi(self): " prepare and build XPI " if self.package.type == "l": raise Exception("only Add-ons may build a XPI") if not self.sdk: raise Exception("only Add-ons with assigned SDK may build XPI") sdk_dir = self.get_sdk_dir() sdk_source = self.sdk.get_source_dir() # TODO: consider SDK staying per PackageRevision... if os.path.isdir(sdk_dir): xpi_remove(sdk_dir) sdk_copy(sdk_source, sdk_dir) self.export_keys(sdk_dir) self.export_files_with_dependencies("%s/packages" % sdk_dir) return xpi_build(sdk_dir, "%s/packages/%s" % (sdk_dir, self.package.get_unique_package_name()))
def test_xpi_with_empty_dependency(self): " empty lib is created " lib = Package.objects.create( full_name=TEST_LIBRARY_FULLNAME, author=self.user, type='l' ) librev = PackageRevision.objects.filter(package__id_number=lib.id_number)[0] self.addonrev.dependency_add(librev) sdk_copy(SDKDIR) self.addonrev.export_files_with_dependencies('%s/packages' % SDKDIR) out = xpi_build(SDKDIR, '%s/packages/%s' % (SDKDIR, self.addon.get_unique_package_name())) # assert no error output self.assertEqual('', out[1]) # assert xpi was created self.failUnless(os.path.isfile('%s/packages/%s/%s.xpi' % ( SDKDIR, self.addon.get_unique_package_name(), self.addon.name)))
def test_copying_sdk(self): sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.failUnless(os.path.isdir(self.SDKDIR))
def test_copying_sdk(self): sdk_copy(SDKDIR) self.failUnless(os.path.isdir(SDKDIR))