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