def test_minimal_xpi_creation(self): " xpi build from an addon straight after creation " xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies("%s/packages" % self.SDKDIR) (xpi_target, out, err) = xpi_utils.build( self.SDKDIR, self.addon.get_dir_name("%s/packages" % self.SDKDIR), self.addon.name, self.hashtag ) # assert no error output self.assertEqual("", err) # assert xpi was created self.failUnless(os.path.isfile(os.path.join(settings.XPI_TARGETDIR, xpi_target)))
def test_xpi_with_dependency(self): " addon has one dependency with a file " self.addonrev.dependency_add(self.librev) xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies("%s/packages" % self.SDKDIR) (xpi_target, out, err) = xpi_utils.build( self.SDKDIR, self.addon.get_dir_name("%s/packages" % self.SDKDIR), self.addon.name, self.hashtag ) # assert no error output self.assertEqual("", err) # assert xpi was created self.failUnless(os.path.isfile(os.path.join(settings.XPI_TARGETDIR, xpi_target)))
def test_addon_with_other_modules(self): " addon has now more modules " self.addonrev.module_create(filename="test_filename", author=self.author) xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies("%s/packages" % self.SDKDIR) (xpi_target, out, err) = xpi_utils.build( self.SDKDIR, self.addon.get_dir_name("%s/packages" % self.SDKDIR), self.addon.name, self.hashtag ) # assert no error output self.assertEqual("", err) self.failUnless(out) # assert xpi was created self.failUnless(os.path.isfile(os.path.join(settings.XPI_TARGETDIR, xpi_target)))
def test_xpi_with_empty_dependency(self): " empty lib is created " lib = Package.objects.create(full_name="Test Library XPI", author=self.author, type="l") librev = PackageRevision.objects.filter(package__id_number=lib.id_number)[0] self.addonrev.dependency_add(librev) xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies("%s/packages" % self.SDKDIR) (xpi_target, out, err) = xpi_utils.build( self.SDKDIR, self.addon.get_dir_name("%s/packages" % self.SDKDIR), self.addon.name, self.hashtag ) # assert no error output self.assertEqual("", err) # assert xpi was created self.failUnless(os.path.isfile(os.path.join(settings.XPI_TARGETDIR, xpi_target)))
def test_minimal_xpi_creation(self): " xpi build from an addon straight after creation " xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies( '%s/packages' % self.SDKDIR) err = xpi_utils.build( self.SDKDIR, self.addon.latest.get_dir_name('%s/packages' % self.SDKDIR), self.addon.name, self.hashtag) # assert no error output assert not err[1] # assert xpi was created self.failUnless(os.path.isfile( "%s.xpi" % os.path.join(settings.XPI_TARGETDIR, self.hashtag)))
def test_minimal_xpi_creation(self): " xpi build from an addon straight after creation " tstart = time.time() xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies( '%s/packages' % self.SDKDIR) err = xpi_utils.build( self.SDKDIR, self.addon.latest.get_dir_name('%s/packages' % self.SDKDIR), self.addon.name, self.hashtag, tstart=tstart) # assert no error output assert not err[1] # assert xpi was created assert os.path.isfile('%s.xpi' % self.target_basename) assert os.path.isfile('%s.json' % self.target_basename)
def test_xpi_with_dependency(self): " addon has one dependency with a file " self.addonrev.dependency_add(self.librev) xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies( '%s/packages' % self.SDKDIR) err = xpi_utils.build( self.SDKDIR, self.addon.latest.get_dir_name('%s/packages' % self.SDKDIR), self.addon.name, self.hashtag) # assert no error output assert not err[1] # assert xpi was created self.failUnless(os.path.isfile( "%s.xpi" % os.path.join(settings.XPI_TARGETDIR, self.hashtag)))
def test_xpi_with_dependency(self): " addon has one dependency with a file " self.addonrev.dependency_add(self.librev) tstart = time.time() xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies( '%s/packages' % self.SDKDIR) err = xpi_utils.build( self.SDKDIR, self.addon.latest.get_dir_name('%s/packages' % self.SDKDIR), self.addon.name, self.hashtag, tstart=tstart) # assert no error output assert not err[1] # assert xpi was created assert os.path.isfile('%s.xpi' % self.target_basename) assert os.path.isfile('%s.json' % self.target_basename)
def test_building_xpi(self): sdk = SDK.objects.create(version=settings.LOWEST_APPROVED_SDK, dir=settings.TEST_SDK) package = Package.objects.create(author=self.author, type='a') tstart = time.time() xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) package.latest.export_keys(self.SDKDIR) package.latest.export_files_with_dependencies( '%s/packages' % self.SDKDIR) err = xpi_utils.build( self.SDKDIR, package.latest.get_dir_name('%s/packages' % self.SDKDIR), package.name, self.hashtag, tstart=tstart) # assert no error output assert not err[1] # assert xpi was created assert os.path.isfile('%s.xpi' % self.target_basename) assert os.path.isfile('%s.json' % self.target_basename)
def test_minimal_xpi_creation(self): " xpi build from an addon straight after creation " tstart = time.time() xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies('%s/packages' % self.SDKDIR) err = xpi_utils.build(self.SDKDIR, self.addon.latest.get_dir_name('%s/packages' % self.SDKDIR), self.addon.name, self.hashtag, tstart=tstart) # assert no error output assert not err[1] # assert xpi was created assert os.path.isfile('%s.xpi' % self.target_basename) assert os.path.isfile('%s.json' % self.target_basename)
def rebuild(self, sdk_source_dir, hashtag, package_overrides={}): """Drive the rebuild process :param: sdk_source_dir (String) absolute path of the SDK :param: hashtag (String) filename for the buid XPI :param: target_version (String) """ self.get_manifest(package_overrides=package_overrides) sdk_dir = self.extract_packages(sdk_source_dir) # build xpi log.debug("[%s] Rebuilding XPI" % hashtag) response = xpi_utils.build(sdk_dir, os.path.join(sdk_dir, 'packages', self.manifest['name']), self.manifest['name'], hashtag) log.debug("[%s] Done rebuilding XPI; cleaning up" % hashtag) # clean up (sdk_dir is already removed) self.cleanup() return response
def test_xpi_with_dependency(self): " addon has one dependency with a file " self.addonrev.dependency_add(self.librev) tstart = time.time() xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies('%s/packages' % self.SDKDIR) err = xpi_utils.build(self.SDKDIR, self.addon.latest.get_dir_name('%s/packages' % self.SDKDIR), self.addon.name, self.hashtag, tstart=tstart) # assert no error output assert not err[1] # assert xpi was created assert os.path.isfile('%s.xpi' % self.target_basename) assert os.path.isfile('%s.json' % self.target_basename)
def test_addon_with_other_modules(self): " addon has now more modules " self.addonrev.module_create( filename='test_filename', author=self.author ) xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies( '%s/packages' % self.SDKDIR) err = xpi_utils.build( self.SDKDIR, self.addon.latest.get_dir_name('%s/packages' % self.SDKDIR), self.addon.name, self.hashtag) # assert no error output assert not err[1] # assert xpi was created self.failUnless(os.path.isfile( "%s.xpi" % os.path.join(settings.XPI_TARGETDIR, self.hashtag)))
def test_addon_with_other_modules(self): " addon has now more modules " self.addonrev.module_create(filename="test_filename", author=self.author) tstart = time.time() xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies("%s/packages" % self.SDKDIR) err = xpi_utils.build( self.SDKDIR, self.addon.latest.get_dir_name("%s/packages" % self.SDKDIR), self.addon.name, self.hashtag, tstart=tstart, ) # assert no error output assert not err[1] # assert xpi was created assert os.path.isfile("%s.xpi" % self.target_basename) assert os.path.isfile("%s.json" % self.target_basename)
def rebuild(self, sdk_source_dir, hashtag, package_overrides={}, options=None): """ Drive the rebuild process :param: sdk_source_dir (String) absolute path of the SDK :param: hashtag (String) filename for the buid XPI :param: target_version (String) """ self.get_manifest(package_overrides=package_overrides) sdk_dir = self.extract_packages(sdk_source_dir) log.debug('[%s] Manifest: %s' % (hashtag, self.manifest)) # build xpi log.debug("[%s] Rebuilding XPI" % hashtag) response = xpi_utils.build(sdk_dir, os.path.join(sdk_dir, 'packages', self.manifest['name']), self.manifest['name'], hashtag, options=options) # here find the created XPI and compare main dir list # if not the same - copy the files from original XPI target = os.path.join(settings.XPI_TARGETDIR, '%s.xpi' % hashtag) target_zip = zipfile.ZipFile(target, 'a') target_namelist = target_zip.namelist() for f in self.xpi_zip.namelist(): if len(f.split('/')) == 1 and f not in target_namelist: log.debug(f) # export file from original xpi and pack file into target xpi with tempfile.NamedTemporaryFile() as extr_file: extr_file.write(self.xpi_zip.open(f).read()) target_zip.write(extr_file.name, f) target_zip.close() # clean up (sdk_dir is already removed) log.debug("[%s] Done rebuilding XPI; cleaning up" % hashtag) self.cleanup() return response
def test_building_xpi_with_1_12(self): sdk = SDK.objects.create(version="1.12", dir="addon-sdk-1.12") package = Package.objects.create(author=self.author, type="a") tstart = time.time() xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) package.latest.export_keys(self.SDKDIR) package.latest.export_files_with_dependencies("%s/packages" % self.SDKDIR) err = xpi_utils.build( self.SDKDIR, package.latest.get_dir_name("%s/packages" % self.SDKDIR), package.name, self.hashtag, tstart=tstart, ) # assert no error output assert not err[1] # assert xpi was created assert os.path.isfile("%s.xpi" % self.target_basename) assert os.path.isfile("%s.json" % self.target_basename)
def test_building_xpi_with_1_12(self): sdk = SDK.objects.create(version='1.12', dir='addon-sdk-1.12') package = Package.objects.create(author=self.author, type='a') tstart = time.time() xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) package.latest.export_keys(self.SDKDIR) package.latest.export_files_with_dependencies('%s/packages' % self.SDKDIR) err = xpi_utils.build(self.SDKDIR, package.latest.get_dir_name('%s/packages' % self.SDKDIR), package.name, self.hashtag, tstart=tstart) # assert no error output assert not err[1] # assert xpi was created assert os.path.isfile('%s.xpi' % self.target_basename) assert os.path.isfile('%s.json' % self.target_basename)
def test_addon_with_other_modules(self): " addon has now more modules " self.addonrev.module_create(filename='test_filename', author=self.author) tstart = time.time() xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies('%s/packages' % self.SDKDIR) err = xpi_utils.build(self.SDKDIR, self.addon.latest.get_dir_name('%s/packages' % self.SDKDIR), self.addon.name, self.hashtag, tstart=tstart) # assert no error output assert not err[1] # assert xpi was created assert os.path.isfile('%s.xpi' % self.target_basename) assert os.path.isfile('%s.json' % self.target_basename)
def test_xpi_with_empty_dependency(self): " empty lib is created " lib = Package.objects.create(full_name="Test Library XPI", author=self.author, type="l") librev = lib.latest self.addonrev.dependency_add(librev) tstart = time.time() xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies("%s/packages" % self.SDKDIR) err = xpi_utils.build( self.SDKDIR, self.addon.latest.get_dir_name("%s/packages" % self.SDKDIR), self.addon.name, self.hashtag, tstart=tstart, ) # assert no error output assert not err[1] # assert xpi was created assert os.path.isfile("%s.xpi" % self.target_basename) assert os.path.isfile("%s.json" % self.target_basename)
def test_xpi_with_empty_dependency(self): " empty lib is created " lib = Package.objects.create( full_name='Test Library XPI', author=self.author, type='l' ) librev = PackageRevision.objects.filter( package__id_number=lib.id_number)[0] self.addonrev.dependency_add(librev) xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies( '%s/packages' % self.SDKDIR) err = xpi_utils.build( self.SDKDIR, self.addon.latest.get_dir_name('%s/packages' % self.SDKDIR), self.addon.name, self.hashtag) # assert no error output assert not err[1] # assert xpi was created self.failUnless(os.path.isfile( "%s.xpi" % os.path.join(settings.XPI_TARGETDIR, self.hashtag)))
def test_xpi_with_empty_dependency(self): " empty lib is created " lib = Package.objects.create(full_name='Test Library XPI', author=self.author, type='l') librev = lib.latest self.addonrev.dependency_add(librev) tstart = time.time() xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies('%s/packages' % self.SDKDIR) err = xpi_utils.build(self.SDKDIR, self.addon.latest.get_dir_name('%s/packages' % self.SDKDIR), self.addon.name, self.hashtag, tstart=tstart) # assert no error output assert not err[1] # assert xpi was created assert os.path.isfile('%s.xpi' % self.target_basename) assert os.path.isfile('%s.json' % self.target_basename)
def rebuild(self, sdk_source_dir, hashtag, package_overrides={}, options=None): """ Drive the rebuild process :param: sdk_source_dir (String) absolute path of the SDK :param: hashtag (String) filename for the buid XPI :param: target_version (String) """ self.get_manifest(package_overrides=package_overrides) log.debug('[%s] Manifest: %s' % (hashtag, self.manifest)) sdk_dir = self.extract_packages(sdk_source_dir) # build xpi log.debug("[%s] Rebuilding XPI" % hashtag) response = xpi_utils.build(sdk_dir, os.path.join(sdk_dir, 'packages', self.manifest['name']), self.manifest['name'], hashtag, options=options) # here find the created XPI and compare main dir list # if not the same - copy the files from original XPI target = os.path.join(settings.XPI_TARGETDIR, '%s.xpi' % hashtag) target_zip = zipfile.ZipFile(target, 'a') target_namelist = target_zip.namelist() for f in self.xpi_zip.namelist(): if len(f.split('/')) == 1 and f not in target_namelist: log.debug(f) # export file from original xpi and pack file into target xpi with tempfile.NamedTemporaryFile() as extr_file: extr_file.write(self.xpi_zip.open(f).read()) target_zip.write(extr_file.name, f) target_zip.close() # clean up (sdk_dir is already removed) log.debug("[%s] Done rebuilding XPI; cleaning up" % hashtag) self.cleanup() return response
def test_xpi_with_empty_dependency(self): " empty lib is created " lib = Package.objects.create( full_name='Test Library XPI', author=self.author, type='l' ) librev = PackageRevision.objects.filter( package__id_number=lib.id_number)[0] self.addonrev.dependency_add(librev) tstart = time.time() xpi_utils.sdk_copy(self.addonrev.sdk.get_source_dir(), self.SDKDIR) self.addonrev.export_keys(self.SDKDIR) self.addonrev.export_files_with_dependencies( '%s/packages' % self.SDKDIR) err = xpi_utils.build( self.SDKDIR, self.addon.latest.get_dir_name('%s/packages' % self.SDKDIR), self.addon.name, self.hashtag, tstart=tstart) # assert no error output assert not err[1] # assert xpi was created assert os.path.isfile('%s.xpi' % self.target_basename) assert os.path.isfile('%s.json' % self.target_basename)
def xpi_build(sdk_dir, package_dir, filename, hashtag): log.info('[1@%s] Building XPI: %s' % (xpi_build.rate_limit, filename)) xpi_utils.build(sdk_dir, package_dir, filename, hashtag)