source: issm/oecreview/Archive/20545-21336/ISSM-20780-20781.diff@ 21337

Last change on this file since 21337 was 21337, checked in by Mathieu Morlighem, 8 years ago

CHG: added Archive/20545-21336

File size: 2.0 KB
  • ../trunk-jpl/jenkins/javascript/karma/scripts/specs/generate-spec.sh

     
     1#!/bin/sh
     2
     3# Create array to store numbers of the tests
     4TESTNUMBERS=()
     5
     6# Location of test scripts
     7SCRIPTDIR=$ISSM_DIR/jenkins/javascript/karma/scripts
     8
     9OLDIFS=$IFS
     10IFS=, # Overwrite the in-field-separator to detect ranges of numbers as numbers separated by commas
     11
     12# Add the test numbers to the array
     13for range in $1; do
     14    if [[ ! "$range" =~ "-" ]]; then # check if it is a range of numbers or just a single number
     15        TESTNUMBERS+=($range)
     16    else
     17        SEQUENCE=($(seq -w -s ' ' $(sed "s/-/$IFS/" <<< ${range})))
     18        TESTNUMBERS=("${TESTNUMBERS[@]}" "${SEQUENCE[@]}")
     19    fi
     20done
     21
     22IFS=$OLDIFS # Reset the in-field-separator
     23
     24# Include necessary functions and constants
     25cat << EOF
     26window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; // Change timeout for Jasmine tests
     27var AJAX_TIMEOUT = 5000;
     28function onAjaxSuccess(data, status, jqxhr) {
     29    console.log("Success");
     30}
     31function onAjaxError(jqxhr, status, err) {
     32    console.log("Unexpected error: " + err);
     33}
     34EOF
     35
     36# Create stubs for individual tests
     37for num in ${TESTNUMBERS[@]}; do
     38cat  << EOF
     39describe("test$num", function() {
     40    it("contains test$num", function(done) {
     41        $.ajax({
     42            url: 'http://localhost:8080/test$num.js',
     43            dataType: 'script',
     44            success: onAjaxSuccess,
     45            error: onAjaxError,
     46            complete: function(jqxhr, status) { done(); },
     47            timeout: AJAX_TIMEOUT
     48        });
     49    });
     50});
     51EOF
     52done
Note: See TracBrowser for help on using the repository browser.