-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from Jumpaku/test/cli-test
CLI testing
- Loading branch information
Showing
188 changed files
with
2,288 additions
and
10,517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.DEFAULT_GOAL := help | ||
.PHONY: help | ||
help: ## Show help | ||
@grep -E '^[a-zA-Z_-]+:.*?##.*$$' $(MAKEFILE_LIST) | \ | ||
awk 'BEGIN {FS = ":.*?##"}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' | ||
|
||
.PHONY: cli | ||
cli: ## Generates CLIs to be tested | ||
for cli_yaml in cli/*.yaml; do \ | ||
group=$$(basename "$${cli_yaml}" .yaml); \ | ||
cyamli generate dart < "cli/$${group}.yaml" > "dart/$${group}/cli.g.dart"; \ | ||
cyamli generate golang -package=main < "cli/$${group}.yaml" > "golang/$${group}/cli.gen.go"; \ | ||
cyamli generate python3 < "cli/$${group}.yaml" > "python3/$${group}/cli_gen.py"; \ | ||
done | ||
|
||
.PHONY: testcases | ||
testcases: ## Generates testcases | ||
go run ./internal/gen-testcases . | ||
|
||
.PHONY: run_test | ||
run_test: ## Run tests | ||
docker compose up --exit-code-from=test-dart --abort-on-container-exit test-dart | ||
docker compose up --exit-code-from=test-golang --abort-on-container-exit test-golang | ||
docker compose up --exit-code-from=test-python3 --abort-on-container-exit test-python3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
options: | ||
-opt-integer: | ||
short: -i | ||
type: integer | ||
-opt-boolean: | ||
short: -b | ||
type: boolean | ||
-opt-string: | ||
short: -s | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
arguments: | ||
- name: arg_integer | ||
type: integer | ||
- name: arg_boolean | ||
type: boolean | ||
- name: arg_string | ||
type: string | ||
- name: arg_variadic | ||
variadic: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
subcommands: | ||
sub: | ||
options: | ||
-opt-integer: | ||
short: -i | ||
type: integer | ||
-opt-boolean: | ||
short: -b | ||
type: boolean | ||
-opt-string: | ||
short: -s | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
subcommands: | ||
sub: | ||
arguments: | ||
- name: arg_integer | ||
type: integer | ||
- name: arg_boolean | ||
type: boolean | ||
- name: arg_string | ||
type: string | ||
- name: arg_variadic | ||
variadic: true |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'cli.g.dart'; | ||
|
||
void main(List<String> args) { | ||
final cli = CLI(); | ||
cli.FUNC = (subcommand, input, inputErr) { | ||
if (inputErr != null) { | ||
throw inputErr; | ||
} | ||
print( | ||
"${subcommand.join("-")}_${input?.optOptInteger}_${input?.optOptBoolean}_${input?.optOptString}"); | ||
}; | ||
run(cli, args); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/sh | ||
# Code generated by go run ./cli-test/internal/gen-testcases/... DO NOT EDIT! | ||
|
||
run_test() { | ||
message=$1 | ||
want=$2 | ||
entrypoint=$3 | ||
shift 3 | ||
got=$( ${entrypoint} $@ ) | ||
|
||
if [ "${got}" = "${want}" ]; then | ||
echo "OK: ${message}" | ||
else | ||
echo "NG: ${message}" | ||
echo " execution: ${entrypoint} $@" | ||
echo " want: '${want}'" | ||
echo " got: '${got}'" | ||
fi | ||
} | ||
|
||
|
||
run_test 'root command should handle optional arguments of type integer' \ | ||
'_123_false_' \ | ||
dart main.dart -opt-integer=123 | ||
|
||
run_test 'root command should handle optional arguments of type boolean' \ | ||
'_0_true_' \ | ||
dart main.dart -opt-boolean=true | ||
|
||
run_test 'root command should handle optional arguments of type boolean' \ | ||
'_0_false_abc' \ | ||
dart main.dart -opt-string=abc | ||
|
||
run_test 'root command should handle optional arguments of type integer' \ | ||
'_123_false_' \ | ||
dart main.dart -i=123 | ||
|
||
run_test 'root command should handle short optional arguments of type boolean' \ | ||
'_0_true_' \ | ||
dart main.dart -b=true | ||
|
||
run_test 'root command should handle short optional arguments of type boolean' \ | ||
'_0_false_abc' \ | ||
dart main.dart -s=abc | ||
|
||
run_test 'root command should handle default optional argument values' \ | ||
'_0_false_' \ | ||
dart main.dart | ||
|
||
run_test 'root command should handle optional arguments of type boolean without value' \ | ||
'_0_true_' \ | ||
dart main.dart -opt-boolean | ||
|
||
run_test 'root command should handle short optional arguments of type boolean without value' \ | ||
'_0_true_' \ | ||
dart main.dart -b | ||
|
Oops, something went wrong.