[fuchsia] Add --gtest-filter flag for unit tests. (flutter/engine#36509)
This commit is contained in:
@@ -30,3 +30,9 @@ $ENGINE_DIR/flutter/tools/fuchsia/devshell/run_unit_tests.sh
|
||||
```sh
|
||||
$ENGINE_DIR/flutter/tools/fuchsia/devshell/run_unit_tests.sh --package-filter flow_tests-0.far
|
||||
```
|
||||
|
||||
- Pass `--gtest-filter` to run specific tests from the test package instead of all the tests. For example:
|
||||
|
||||
```sh
|
||||
$ENGINE_DIR/flutter/tools/fuchsia/devshell/run_unit_tests.sh --package-filter flutter_runner_tests-0.far --gtest-filter "*FlatlandConnection*"
|
||||
```
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
###
|
||||
### Arguments:
|
||||
### --package-filter: Only runs tests in packages that match the given `find` statement.
|
||||
### --gtest-filter: In the packages, only runs tests that match the given filter.
|
||||
### For example: --gtest-filter "*FlatlandConnection*" to run any tests
|
||||
### that have the phrase FlatlandConnection in them.
|
||||
### --unoptimized: Disables C++ compiler optimizations.
|
||||
### --count: Number of times to run the test. By default runs 1 time.
|
||||
### See `ffx test run --count`.
|
||||
@@ -27,19 +30,20 @@ goma=0
|
||||
goma_flags=""
|
||||
ninja_cmd="ninja"
|
||||
package_filter="*tests-0.far"
|
||||
test_filter_flags=""
|
||||
unoptimized_flags=""
|
||||
unoptimized_suffix=""
|
||||
count_flag=""
|
||||
count_flags=""
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--package-filter)
|
||||
--package_filter|--package-filter)
|
||||
shift # past argument
|
||||
package_filter="$1"
|
||||
shift # past value
|
||||
;;
|
||||
--count)
|
||||
shift # past argument
|
||||
count_flag="--count $1"
|
||||
count_flags="--count $1"
|
||||
shift # past value
|
||||
;;
|
||||
--goma)
|
||||
@@ -53,6 +57,11 @@ while [[ $# -gt 0 ]]; do
|
||||
unoptimized_suffix="_unopt"
|
||||
shift # past argument
|
||||
;;
|
||||
--gtest_filter|--gtest-filter)
|
||||
shift # past argument
|
||||
test_filter_flags="-- --gtest_filter=$1"
|
||||
shift # past value
|
||||
;;
|
||||
*)
|
||||
engine-error "Unknown argument: $1"
|
||||
exit 1
|
||||
@@ -98,7 +107,8 @@ do
|
||||
engine-warning "Skipping txt_tests because I don't know how to filter out ParagraphTests.*"
|
||||
continue
|
||||
fi
|
||||
test_cmd="${FUCHSIA_DIR}/.jiri_root/bin/ffx test run fuchsia-pkg://fuchsia.com/${test_name}#meta/${test_name}.cm ${count_flag}"
|
||||
# ${test_filter_flags} must come last below because it includes " -- " to start program arguments.
|
||||
test_cmd="${FUCHSIA_DIR}/.jiri_root/bin/ffx test run fuchsia-pkg://fuchsia.com/${test_name}#meta/${test_name}.cm ${count_flags} ${test_filter_flags}"
|
||||
|
||||
engine-info "... $test_cmd ..."
|
||||
$test_cmd
|
||||
|
||||
30
engine/src/flutter/tools/fuchsia/devshell/test/test_run_unit_tests.sh
Executable file
30
engine/src/flutter/tools/fuchsia/devshell/test/test_run_unit_tests.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
#
|
||||
### Tests run_unit_tests.sh by running it with various arguments.
|
||||
### This script doesn't assert the results but just checks that the script runs
|
||||
### successfully every time.
|
||||
###
|
||||
### This script doesn't run on CQ, it's only used for local testing.
|
||||
|
||||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/../lib/vars.sh || exit $?
|
||||
|
||||
ensure_engine_dir
|
||||
|
||||
set -e # Fail on any error.
|
||||
|
||||
engine-info "Testing run_unit_tests.sh --package-filter flutter_runner_tests-0.far..."
|
||||
"$ENGINE_DIR"/flutter/tools/fuchsia/devshell/run_unit_tests.sh --package-filter "flutter_runner_tests-0.far"
|
||||
|
||||
engine-info "Testing run_unit_tests.sh --package-filter flutter_runner_tests-0.far --count 2..."
|
||||
"$ENGINE_DIR"/flutter/tools/fuchsia/devshell/run_unit_tests.sh --package-filter "flutter_runner_tests-0.far" --count 2
|
||||
|
||||
|
||||
engine-info "Testing run_unit_tests.sh --package-filter flutter_runner_tests-0.far --gtest-filter *FlatlandConnection*..."
|
||||
"$ENGINE_DIR"/flutter/tools/fuchsia/devshell/run_unit_tests.sh --package-filter "flutter_runner_tests-0.far" --gtest-filter "*FlatlandConnection*"
|
||||
|
||||
engine-info "Testing run_unit_tests.sh with no args..."
|
||||
"$ENGINE_DIR"/flutter/tools/fuchsia/devshell/run_unit_tests.sh
|
||||
|
||||
Reference in New Issue
Block a user