<commit_before>#!/bin/bash

echo_fail()
{
  echo -e "\033[31m${1}";
}

echo_ok()
{
  echo -e "\033[32m✓ \033[0m${1}";
}

PLATFORM=$1
PLATFORM=$(echo $PLATFORM | awk '{print tolower($0)}')

# help
if [ "${PLATFORM}" == help ]; 
then
  echo_fail "Usage cordova-test [platform] [appium_tests_full_path]"
  exit 0
fi

# check tests directory exists
TEST_PATH=$"${PWD}/$2"
if [ ! -d "$TEST_PATH" ];
then
  echo_fail "Tests directory not found; $TEST_PATH"
  exit 1
fi
echo_ok "Checking tests directory exists"

#check platforms
SUPPORTED_PLATFORM[0]=android
# SUPPORTED_PLATFORM[1]=ios
IS_SUPPORTED=0
for i in "${!SUPPORTED_PLATFORM[@]}"; do
  if [ "${SUPPORTED_PLATFORM[$i]}" = "${PLATFORM}" ];
  then
    IS_SUPPORTED=1
    break
  fi
done

if [ $IS_SUPPORTED -eq 0 ]; then
  echo_fail "Platform not supported; $PLATFORM"
  exit 1
fi
echo_ok "Checking selected platform is supported"

# check appum is running
IS_RUNNING=$(curl -v --max-time 2 --silent http://1192.168.3.11:4723/wd/hub/status 2>&1 | grep \"status\":0)
if [ -z $IS_RUNNING ];
then
  echo_fail "Appium is not running or available, run appium &"
  exit 0;
fi
echo_ok "Checking appium is running"

# compile cordova app
NO_COMPILE=1
for i in "$@"
do
  if [ $i = '--no-compile' ];
  then
    NO_COMPILE=0
    break
  fi
done

if [ $NO_COMPILE -eq 1 ];
then
  echo "Compiling cordova application, this could take a while!"
  cordova build $PLATFORM
  echo_ok "Cordova app compiled"
fi

# getting platform app path
echo "Getting compiled application path"<commit_msg>update comment<commit_after>#!/bin/bash

echo_fail()
{
  echo -e "\033[31m${1}";
}

echo_ok()
{
  echo -e "\033[32m✓ \033[0m${1}";
}

PLATFORM=$1
PLATFORM=$(echo $PLATFORM | awk '{print tolower($0)}')

# help
if [ "${PLATFORM}" == help ]; 
then
  echo_fail "Usage cordova-test [platform] [appium_tests_full_path]"
  exit 0
fi

# check tests directory exists
TEST_PATH=$"${PWD}/$2"
if [ ! -d "$TEST_PATH" ];
then
  echo_fail "Tests directory not found; $TEST_PATH"
  exit 1
fi
echo_ok "Checking tests directory exists"

#check platforms
SUPPORTED_PLATFORM[0]=android
# SUPPORTED_PLATFORM[1]=ios
IS_SUPPORTED=0
for i in "${!SUPPORTED_PLATFORM[@]}"; do
  if [ "${SUPPORTED_PLATFORM[$i]}" = "${PLATFORM}" ];
  then
    IS_SUPPORTED=1
    break
  fi
done

if [ $IS_SUPPORTED -eq 0 ]; then
  echo_fail "Platform not supported; $PLATFORM"
  exit 1
fi
echo_ok "Checking selected platform is supported"

# check appum is running
IS_RUNNING=$(curl -v --max-time 2 --silent http://127.0.0.1:4723/wd/hub/status 2>&1 | grep \"status\":0)
if [ -z $IS_RUNNING ];
then
  echo_fail "Appium is not running or available, run appium &"
  exit 0;
fi
echo_ok "Checking appium is running"

# compile cordova app
NO_COMPILE=1
for i in "$@"
do
  if [ $i = '--no-compile' ];
  then
    NO_COMPILE=0
    break
  fi
done

if [ $NO_COMPILE -eq 1 ];
then
  echo "Compiling cordova application, this may take a while!"
  COMPILE=$(cordova build $PLATFORM)
  echo_ok "Cordova app compiled"
fi

# getting platform app path
echo "Getting compiled application path"
{'fraction_non_alphanumeric': 0.14145383104125736, 'fraction_numerical': 0.03077930582842174, 'mean_word_length': 4.091666666666667, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4562694', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1173, 'n_words': 340}