source/projects/bazelshim/test/test_normalizer.py

75 lines
1.6 KiB
Python
Raw Normal View History

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