<commit_before>#!/usr/bin/env bash

# Copyright 2014 The Oppia Authors. All Rights Reserved.
#
# Licensed 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.

##########################################################################

# INSTRUCTIONS:
#
# Run this script from the oppia root folder:
#   bash scripts/run_e2e_tests.sh
#
# Optional arguments:
#   --browserstack Run the tests on browserstack using the
#         protractor-browserstack.conf.js file.
#   --skip-install=true/false If true, skips installing dependencies. The
#         default value is false.
#   --sharding=true/false Disables/Enables parallelization of protractor tests.
#   --sharding-instances=# Sets the number of parallel browsers to open while
#         sharding.
#   --prod_env Run the tests in prod mode. Static resources are served from
#         build directory and use cache slugs.
# Sharding must be disabled (either by passing in false to --sharding or 1 to
# --sharding-instances) if running any tests in isolation (fit or fdescribe).
#   --suite=suite_name Performs test for different suites, here suites are the
#         name of the test files present in core/tests/protractor_desktop/ and
#         core/test/protractor/ dirs. e.g. for the file
#         core/tests/protractor/accessibility.js use --suite=accessibility.
#         For performing a full test, no argument is required.
#
# The root folder MUST be named 'oppia'.
#
# Note: You can replace 'it' with 'fit' or 'describe' with 'fdescribe' to run a
# single test or test suite.

function cleanup {
  # Send a kill signal to the dev server and Selenium server. The awk command
  # gets just the process ID from the grepped line.
  kill `ps aux | grep "[Dd]ev_appserver.py --host=0.0.0.0 --port=9001" | awk '{print $2}'` || true
  kill `ps aux | grep node_modules/webdriver-manager/selenium | awk '{print $2}'` || true

  if [ -d "../protractor-screenshots" ]; then
    echo ""
    echo "  Note: If ADD_SCREENSHOT_REPORTER is set to true in"
    echo "  core/tests/protractor.conf.js, you can view screenshots"
    echo "  of the failed tests in ../protractor-screenshots/"
    echo ""
  fi

  echo Done!
}

if [ -z "$BASH_VERSION" ]
then
  echo ""
  echo "  Please run me using bash: "
  echo ""
  echo "     bash $0"
  echo ""
  return 1
fi

set -e
python -m scripts.setup
python -m scripts.setup_gae
if [ "$TRAVIS" == 'true' ]; then
  python -m scripts.install_chrome_on_travis
fi

if ( nc -vz localhost 8181 ); then
  echo ""
  echo "  There is already a server running on localhost:8181."
  echo "  Please terminate it before running the end-to-end tests."
  echo "  Exiting."
  echo ""
  exit 1
fi

if ( nc -vz localhost 9001 ); then
  echo ""
  echo " There is a already a server running on localhost:9001."
  echo " Please terminate it before running the end-to-end tests."
  echo " Exiting."
  echo ""
  exit 1
fi

export OPPIA_DIR=`pwd`
# Set COMMON_DIR to the absolute path of the directory above OPPIA_DIR. This
# is necessary becaue COMMON_DIR (or subsequent variables which refer to it)
# may use it in a situation where relative paths won't work as expected (such
# as $PYTHONPATH).<commit_msg>Run install_third_party_libs.py script before running e2e tests (#7918) (#7947)<commit_after>#!/usr/bin/env bash

# Copyright 2014 The Oppia Authors. All Rights Reserved.
#
# Licensed 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.

##########################################################################

# INSTRUCTIONS:
#
# Run this script from the oppia root folder:
#   bash scripts/run_e2e_tests.sh
#
# Optional arguments:
#   --browserstack Run the tests on browserstack using the
#         protractor-browserstack.conf.js file.
#   --skip-install=true/false If true, skips installing dependencies. The
#         default value is false.
#   --sharding=true/false Disables/Enables parallelization of protractor tests.
#   --sharding-instances=# Sets the number of parallel browsers to open while
#         sharding.
#   --prod_env Run the tests in prod mode. Static resources are served from
#         build directory and use cache slugs.
# Sharding must be disabled (either by passing in false to --sharding or 1 to
# --sharding-instances) if running any tests in isolation (fit or fdescribe).
#   --suite=suite_name Performs test for different suites, here suites are the
#         name of the test files present in core/tests/protractor_desktop/ and
#         core/test/protractor/ dirs. e.g. for the file
#         core/tests/protractor/accessibility.js use --suite=accessibility.
#         For performing a full test, no argument is required.
#
# The root folder MUST be named 'oppia'.
#
# Note: You can replace 'it' with 'fit' or 'describe' with 'fdescribe' to run a
# single test or test suite.

function cleanup {
  # Send a kill signal to the dev server and Selenium server. The awk command
  # gets just the process ID from the grepped line.
  kill `ps aux | grep "[Dd]ev_appserver.py --host=0.0.0.0 --port=9001" | awk '{print $2}'` || true
  kill `ps aux | grep node_modules/webdriver-manager/selenium | awk '{print $2}'` || true

  if [ -d "../protractor-screenshots" ]; then
    echo ""
    echo "  Note: If ADD_SCREENSHOT_REPORTER is set to true in"
    echo "  core/tests/protractor.conf.js, you can view screenshots"
    echo "  of the failed tests in ../protractor-screenshots/"
    echo ""
  fi

  echo Done!
}

if [ -z "$BASH_VERSION" ]
then
  echo ""
  echo "  Please run me using bash: "
  echo ""
  echo "     bash $0"
  echo ""
  return 1
fi

set -e
python -m scripts.install_third_party_libs
python -m scripts.setup
python -m scripts.setup_gae
if [ "$TRAVIS" == 'true' ]; then
  python -m scripts.install_chrome_on_travis
fi

if ( nc -vz localhost 8181 ); then
  echo ""
  echo "  There is already a server running on localhost:8181."
  echo "  Please terminate it before running the end-to-end tests."
  echo "  Exiting."
  echo ""
  exit 1
fi

if ( nc -vz localhost 9001 ); then
  echo ""
  echo " There is a already a server running on localhost:9001."
  echo " Please terminate it before running the end-to-end tests."
  echo " Exiting."
  echo ""
  exit 1
fi

export OPPIA_DIR=`pwd`
# Set COMMON_DIR to the absolute path of the directory above OPPIA_DIR. This
# is necessary becaue COMMON_DIR (or subsequent variables which refer to it)
# may use it in a situation where relative paths won't work as expected (such
# as $PYTHONPATH).
{'fraction_non_alphanumeric': 0.10846953937592868, 'fraction_numerical': 0.01202215318114278, 'mean_word_length': 3.357857563272513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2726216', 'n_tokens_mistral': 2316, 'n_tokens_neox': 2172, 'n_words': 926}