source/projects/bazelshim/test/test_parser.py
2024-02-06 12:37:41 -07:00

52 lines
1.3 KiB
Python

#!/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