-
Notifications
You must be signed in to change notification settings - Fork 366
add --filename option to specify a filename template #1900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import defaultEventToPromise from 'event-to-promise'; | |
| import build, { | ||
| safeFileName, | ||
| getDefaultLocalizedName, | ||
| getStringPropertyValue, | ||
| defaultPackageCreator, | ||
| } from '../../../src/cmd/build'; | ||
| import {FileFilter} from '../../../src/util/file-filter'; | ||
|
|
@@ -72,6 +73,40 @@ describe('build', () => { | |
| }); | ||
| }); | ||
|
|
||
| it('throws on missing manifest properties in filename template', () => { | ||
| return withTempDir( | ||
| (tmpDir) => | ||
| build({ | ||
| sourceDir: fixturePath('minimal-web-ext'), | ||
| artifactsDir: tmpDir.path(), | ||
| filename: '{missingKey}-{version}.xpi', | ||
| }) | ||
| .then(makeSureItFails()) | ||
| .catch((error) => { | ||
| log.info(error); | ||
| assert.instanceOf(error, UsageError); | ||
| assert.match( | ||
| error.message, | ||
| /Manifest key "missingKey" is missing/); | ||
| }) | ||
| ); | ||
| }); | ||
|
|
||
| it('gives the correct custom name to an extension', () => { | ||
| return withTempDir( | ||
| (tmpDir) => | ||
| build({ | ||
| sourceDir: fixturePath('minimal-web-ext'), | ||
| artifactsDir: tmpDir.path(), | ||
| filename: '{applications.gecko.id}-{version}.xpi', | ||
| }) | ||
| .then((buildResult) => { | ||
| assert.match(path.basename(buildResult.extensionPath), | ||
| /minimal-example_web-ext-test-suite-1.0\.xpi$/); | ||
| }) | ||
| ); | ||
| }); | ||
|
|
||
| it('gives the correct name to a localized extension', () => { | ||
| return withTempDir( | ||
| (tmpDir) => | ||
|
|
@@ -86,6 +121,44 @@ describe('build', () => { | |
| ); | ||
| }); | ||
|
|
||
| it('throws an error if the filename contains a path', () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit, it would probably good to have also one test that verifies that if an interpolated part of the template is a string that looks like a path then we still throw this kind of UsageError (which is actually the case with the version in this patch, it would be mostly an additional test to have more coverage in case of a refactoring), but we can deal with it in a follow up. |
||
| return withTempDir( | ||
| (tmpDir) => | ||
| build({ | ||
| sourceDir: fixturePath('minimal-web-ext'), | ||
| artifactsDir: tmpDir.path(), | ||
| filename: 'foo/{version}.xpi', | ||
| }) | ||
| .then(makeSureItFails()) | ||
| .catch((error) => { | ||
| log.info(error); | ||
| assert.instanceOf(error, UsageError); | ||
| assert.match( | ||
| error.message, | ||
| /Filename "foo\/1.0.xpi" should not contain a path/); | ||
| }) | ||
| ); | ||
| }); | ||
|
|
||
| it('throws an error if the filename doesn\'t end in .xpi or .zip', () => { | ||
| return withTempDir( | ||
| (tmpDir) => | ||
| build({ | ||
| sourceDir: fixturePath('minimal-web-ext'), | ||
| artifactsDir: tmpDir.path(), | ||
| filename: '{version}.unknown-ext', | ||
| }) | ||
| .then(makeSureItFails()) | ||
| .catch((error) => { | ||
| log.info(error); | ||
| assert.instanceOf(error, UsageError); | ||
| assert.match( | ||
| error.message, | ||
| /Filename "1.0.unknown-ext" should have a zip or xpi extension/); | ||
| }) | ||
| ); | ||
| }); | ||
|
|
||
| it('accept a dash in the default_locale field', () => { | ||
| return withTempDir( | ||
| (tmpDir) => | ||
|
|
@@ -509,4 +582,17 @@ describe('build', () => { | |
|
|
||
| }); | ||
|
|
||
| describe('getStringPropertyValue', () => { | ||
|
|
||
| it('accepts the value 0', () => { | ||
| assert.equal(getStringPropertyValue('foo', {foo: 0}), '0'); | ||
| }); | ||
|
|
||
| it('throws an error if string value is empty', () => { | ||
| assert.throws(() => getStringPropertyValue('foo', {foo: ''}), | ||
| UsageError, /Manifest key "foo" value is an empty string/); | ||
| }); | ||
|
|
||
| }); | ||
|
|
||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, these long.info(error) are not really needed, I just noticed that we did already have one which got merge in a old patch, but not a big deal. We will have to rewrite all these tests into async functions at some point (to make them a bit more readable), and so don't worry about that.