Github user dblotsky commented on a diff in the pull request:

    https://github.com/apache/cordova-medic/pull/77#discussion_r52812697
  
    --- Diff: medic/medic-run.js ---
    @@ -284,6 +289,73 @@ function tryConnect(couchdbURI, pendingNumberOfTries, 
callback) {
         });
     }
     
    +/*
    + * Attempts to start the Android emulator by calling the emulator.js 
script in
    + * the Android platform directory of the app. If the emulator fails to 
boot, we
    + * retry a specified number of times.
    + *
    + * @param {string} appPath          An ABSOLUTE path to the app's project 
folder
    + * @param {number} numberOfTries    Number of times to attempt to start 
the emulator
    + *
    + * @returns {promise}   A promise that resolves to the ID of the emulator 
or
    + *                      null if it failed to start
    + */
    +function startAndroidEmulator(appPath, numberOfTries) {
    +    // We need to get the emulator script from within the Android 
platforms folder
    +    var emuPath = path.join(appPath, "platforms", "android", "cordova", 
"lib", "emulator");
    +    var emulator = require(emuPath);
    +
    +    var tryStart = function(numberTriesRemaining) {
    +        return emulator.start(null, ANDROID_EMU_START_TIMEOUT)
    +        .then(function(emulatorId) {
    +            if (emulatorId) {
    +                return emulatorId;
    +            } else if (numberTriesRemaining > 0) {
    +                // Emulator must have hung while booting, so we need to 
kill it
    +                medicKill(util.ANDROID);
    +                return tryStart(numberTriesRemaining - 1);
    +            } else {
    +                return null;
    +            }
    +        });
    +    };
    +
    +    // Check if the emulator has already been started
    +    return emulator.list_started()
    +    .then(function(started) {
    +        if (started && started.length > 0) {
    +            return started[0];
    +        } else {
    +            return tryStart(numberOfTries);
    +        }
    +    });
    +}
    +
    +/* Starts periodic polling to check for the mobilespec test results in 
CouchDB.
    + * After it finishes polling, it will terminate the process returning a 0 
if
    + * results were found or 1 if they were not.
    + *
    + * @param {string} couchdbURI   The URL for the couchdb instance
    + * @param {string} buildId      The build ID to query the coudchdb for
    + * @param {number} timeout      The amount of time in seconds to continue 
polling
    + */
    +function startPollingForTestResults(couchdbURI, buildId, timeout) {
    +    // NOTE:
    +    //      timeout needs to be in milliseconds, but it's
    +    //      given in seconds, so we multiply by 1000
    --- End diff --
    
    Please move this comment down a line.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to