forked from apache/cordova-android
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Gradle Args parsing (apache#1606)
* fix: Gradle Args parsing * refactor: Applied ARGVParser.parseArgsStringToArgv -> parseArgsStringToArgv suggestion * test: Added deeper testing for gradle argument parsing
- Loading branch information
Showing
6 changed files
with
158 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/* | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
*/ | ||
|
||
const rewire = require('rewire'); | ||
const builders = require('../../lib/builders/builders'); | ||
|
||
describe('build', () => { | ||
let build; | ||
const builder = builders.getBuilder('FakeRootPath'); | ||
|
||
beforeEach(() => { | ||
build = rewire('../../lib/build'); | ||
build.__set__({ | ||
events: jasmine.createSpyObj('eventsSpy', ['emit']) | ||
}); | ||
|
||
// run needs `this` to behave like an Api instance | ||
build.run = build.run.bind({ | ||
_builder: builder | ||
}); | ||
|
||
spyOn(builder, 'build').and.returnValue(Promise.resolve({ | ||
paths: ['fake.apk'], | ||
buildtype: 'debug' | ||
})); | ||
}); | ||
|
||
describe('argument parsing', () => { | ||
let prepEnvSpy; | ||
|
||
beforeEach(() => { | ||
prepEnvSpy = spyOn(builder, 'prepEnv').and.returnValue(Promise.resolve()); | ||
}); | ||
|
||
describe('gradleArg', () => { | ||
const baseOptions = { | ||
packageType: 'apk', | ||
arch: undefined, | ||
prepEnv: undefined, | ||
buildType: 'debug' | ||
}; | ||
|
||
it('can parse single gradle argument', async () => { | ||
await build.run({ | ||
argv: [ | ||
'node', | ||
'--gradleArg=--stacktrace' | ||
] | ||
}); | ||
|
||
expect(prepEnvSpy).toHaveBeenCalledWith({ | ||
...baseOptions, | ||
extraArgs: ['--stacktrace'] | ||
}); | ||
}); | ||
|
||
it('can parse multiple gradle arguments', async () => { | ||
await build.run({ | ||
argv: [ | ||
'node', | ||
'--gradleArg=--stacktrace --info' | ||
] | ||
}); | ||
|
||
expect(prepEnvSpy).toHaveBeenCalledWith({ | ||
...baseOptions, | ||
extraArgs: ['--stacktrace', '--info'] | ||
}); | ||
}); | ||
|
||
it('can parse multiple gradle arguments with strings', async () => { | ||
await build.run({ | ||
argv: [ | ||
'node', | ||
'--gradleArg=--testArg="hello world"' | ||
] | ||
}); | ||
|
||
expect(prepEnvSpy).toHaveBeenCalledWith({ | ||
...baseOptions, | ||
extraArgs: ['--testArg="hello world"'] | ||
}); | ||
}); | ||
|
||
it('gradle args will split when necessary', async () => { | ||
await build.run({ | ||
argv: [ | ||
'node', | ||
'--gradleArg=--warning-mode all' | ||
] | ||
}); | ||
|
||
expect(prepEnvSpy).toHaveBeenCalledWith({ | ||
...baseOptions, | ||
extraArgs: ['--warning-mode', 'all'] | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters