Skip to content

Commit

Permalink
Handle test environment values that contain = in ios_test_runner (#683)
Browse files Browse the repository at this point in the history
Co-authored-by: Keith Smiley <[email protected]>
  • Loading branch information
indragiek and keith authored Aug 11, 2020
1 parent 535790b commit 6ee60b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions apple/testing/default_runner/ios_test_runner.template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ TEST_ENV="%(test_env)s"
if [[ -n "${TEST_ENV}" ]]; then
# Converts the test env string to json format and addes it into launch
# options string.
TEST_ENV=${TEST_ENV//=/\":\"}
TEST_ENV=${TEST_ENV//,/\",\"}
TEST_ENV=$(echo "$TEST_ENV" | awk -F ',' '{for (i=1; i <=NF; i++) { d = index($i, "="); print substr($i, 1, d-1) " " substr($i, d+1); }}')
TEST_ENV=${TEST_ENV// /\":\"}
TEST_ENV=${TEST_ENV//$'\n'/\",\"}
TEST_ENV="{\"${TEST_ENV}\"}"
LAUNCH_OPTIONS_JSON_STR="\"env_vars\":${TEST_ENV}"
fi
Expand Down
8 changes: 8 additions & 0 deletions test/ios_test_runner_unit_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -436,4 +436,12 @@ function test_ios_unit_simulator_id() {
expect_log "error: unsupported --test_arg: 'invalid_arg'"
}

function test_ios_unit_test_with_multi_equal_env() {
create_sim_runners
create_ios_unit_envtest ENV_KEY1 ENV_VALUE2=ENV_VALUE3
do_ios_test --test_env=ENV_KEY1=ENV_VALUE2=ENV_VALUE3 //ios:EnvUnitTest || fail "should pass"

expect_log "Test Suite 'EnvUnitTest' passed"
}

run_suite "ios_unit_test with iOS test runner bundling tests"

0 comments on commit 6ee60b3

Please sign in to comment.