| #!/bin/bash | |
| # Copyright 2021 The Fuchsia Authors. All rights reserved. | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| #### CATEGORY=Test | |
| ### Component integration test auto-generator | |
| ## Usage: fx testgen integration_test --component-manifest <path/to/.cm> -o <path/to/test/root/dir> | |
| ## See 'fx testgen --help' for more help | |
| DEVSHELL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | |
| source "${DEVSHELL_DIR}/lib/vars.sh" || exit $? | |
| # Intercept the output path so we can format code after generation. | |
| args="$@" | |
| COMMAND_OPTS=() | |
| while [[ $# -gt 0 ]]; do | |
| case "$1" in | |
| -o|--test_root) | |
| # Remove all trailing slashes. | |
| shift | |
| output_dir=$(echo $1 | sed 's:/*$::') | |
| break | |
| ;; | |
| *) | |
| shift | |
| ;; | |
| esac | |
| done | |
| fx-config-read | |
| # fx-commmand-run instead of fx-command-exec because exec replaces the current | |
| # process, so only the first command starts. | |
| fx-command-run host-tool testgen $args | |
| if [[ ! -z $output_dir ]]; then | |
| fx-command-run format-code --files="$output_dir/**/*" | |
| fi |