#!/usr/bin/env python3 from shlex import split as shlex from bazelshim.__main__ import BazelCli import pytest @pytest.mark.parametrize( "a, b", [ ( "bazel clean", BazelCli("bazel", [], "clean", [], []), ), ( "bazel --client_debug clean", BazelCli("bazel", ["--client_debug=true"], "clean", [], []), ), ( "bazel build //foo:bar //baz:*", BazelCli("bazel", [], "build", ["//foo:bar", "//baz:*"], []), ), ( "bazel test //foo:bar //baz:* -- -vvv", BazelCli("bazel", [], "test", ["//foo:bar", "//baz:*"], ["-vvv"]), ), ( "bazel test --shell_executable /bin/bish //foo:bar //baz:* -- -vvv", BazelCli( "bazel", [], "test", ["--shell_executable=/bin/bish", "//foo:bar", "//baz:*"], ["-vvv"], ), ), ( "bazel run //foo:bar -- --foo=bar --baz=qux", BazelCli( "bazel", [], "run", ["//foo:bar"], ["--foo=bar", "--baz=qux"], ), ), ], ) def test_normalize_opts(a, b): assert BazelCli.parse_cli(shlex(a)) == b