Skip to content
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

Build and run app separately #172

Open
janpio opened this issue Jun 29, 2019 · 2 comments
Open

Build and run app separately #172

janpio opened this issue Jun 29, 2019 · 2 comments

Comments

@janpio
Copy link
Member

janpio commented Jun 29, 2019

Currently the app is built differently depending on wether you run the tests locally or on SauceLabs. This makes it more difficult to understand what is going on.

Suggestion: Use run -nobuild to run the app (locally), and always build separately and in its own step.

@janpio
Copy link
Member Author

janpio commented Jun 29, 2019

Note: Appium tests also rebuild the app again, because they do some changes.

const buildCommand = this.options.cli + ' build ' + this.options.platform + deviceString + utilities.PARAMEDIC_COMMON_CLI_ARGS;
// remove medic.json and (re)build
shell.rm(path.join(fullAppPath, 'www', 'medic.json'));
fs.stat(fullAppPath, (error, stats) => {
// check if the app exists
if (error || !stats.isDirectory()) {
d.reject('The app directory doesn\'t exist: ' + fullAppPath);
}
// set properties/CSP rules
if (this.options.platform === utilities.IOS) {
appPatcher.setPreference(fullAppPath, 'CameraUsesGeolocation', 'true');
} else if (this.options.platform === utilities.ANDROID) {
appPatcher.setPreference(fullAppPath, 'loadUrlTimeoutValue', 60000);
}
appPatcher.addCspSource(fullAppPath, 'connect-src', 'http://*');
appPatcher.permitAccess(fullAppPath, '*');
// add cordova-save-image-gallery plugin from npm to enable
// Appium tests for camera plugin to save test image to the gallery
runCommand(this.options.cli + ' plugin add cordova-save-image-gallery' + utilities.PARAMEDIC_COMMON_CLI_ARGS, fullAppPath);
// rebuild the app
logger.normal('paramedic-appium: Building the app...');
console.log('$ ' + buildCommand);
child_process.exec(buildCommand, { cwd: fullAppPath, maxBuffer: SMALL_BUFFER_SIZE }, (error, stdout, stderr) => {
if (error || stdout.indexOf('BUILD FAILED') >= 0 || stderr.indexOf('BUILD FAILED') >= 0) {
d.reject('Couldn\'t build the app: ' + error);
} else {
global.PACKAGE_PATH = getPackagePath(this.options);
d.resolve();
}
});

@janpio janpio self-assigned this Jun 29, 2019
@janpio
Copy link
Member Author

janpio commented Jun 29, 2019

#173 splits the build and run for the normal tests, so the build is identical for both local and SauceLabs runs.

@janpio janpio removed their assignment Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant