mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 00:14:41 +01:00
test: split a test to include Windows (#5665)
* test: split a test to include Windows (moving non-Win commands like ls to a separate test) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
5be2fa0a1e
commit
9d49292453
1 changed files with 75 additions and 25 deletions
|
@ -46,16 +46,6 @@ def check_token(xsh):
|
||||||
|
|
||||||
|
|
||||||
_cases = {
|
_cases = {
|
||||||
"ls": {
|
|
||||||
"ls -al": [
|
|
||||||
(Name.Builtin, "ls"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"ls-bin": {
|
|
||||||
"/bin/ls -al": [
|
|
||||||
(Name.Builtin, "/bin/ls"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"print": {
|
"print": {
|
||||||
'print("hello")': [
|
'print("hello")': [
|
||||||
(Name.Builtin, "print"),
|
(Name.Builtin, "print"),
|
||||||
|
@ -94,6 +84,69 @@ _cases = {
|
||||||
(Error, "non-existance-cmd"),
|
(Error, "non-existance-cmd"),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
"nested": {
|
||||||
|
"print($(cd))": [
|
||||||
|
(Name.Builtin, "print"),
|
||||||
|
(Punctuation, "("),
|
||||||
|
(Keyword, "$"),
|
||||||
|
(Punctuation, "("),
|
||||||
|
(Name.Builtin, "cd"),
|
||||||
|
(Punctuation, ")"),
|
||||||
|
(Punctuation, ")"),
|
||||||
|
(Text.Whitespace, "\n"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"subproc-args": {
|
||||||
|
"cd 192.168.0.1": [
|
||||||
|
(Text, "192.168.0.1"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"backtick": {
|
||||||
|
r"echo g`.*\w+`": [
|
||||||
|
(String.Affix, "g"),
|
||||||
|
(String.Backtick, "`"),
|
||||||
|
(String.Regex, "."),
|
||||||
|
(String.Regex, "*"),
|
||||||
|
(String.Escape, r"\w"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"macro": {
|
||||||
|
r"g!(42, *, 65)": [
|
||||||
|
(Name, "g"),
|
||||||
|
(Keyword, "!"),
|
||||||
|
(Punctuation, "("),
|
||||||
|
(Number.Integer, "42"),
|
||||||
|
],
|
||||||
|
r"bash -c ! export var=42; echo $var": [
|
||||||
|
(Name.Builtin, "bash"),
|
||||||
|
(Text, "-c"),
|
||||||
|
(Keyword, "!"),
|
||||||
|
(String, "export var=42; echo $var"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_cases_no_win = {
|
||||||
|
"ls": {
|
||||||
|
"ls -al": [
|
||||||
|
(Name.Builtin, "ls"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"ls-bin": {
|
||||||
|
"/bin/ls -al": [
|
||||||
|
(Name.Builtin, "/bin/ls"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"print": {
|
||||||
|
'print("hello")': [
|
||||||
|
(Name.Builtin, "print"),
|
||||||
|
(Punctuation, "("),
|
||||||
|
(Literal.String.Double, '"'),
|
||||||
|
(Literal.String.Double, "hello"),
|
||||||
|
(Literal.String.Double, '"'),
|
||||||
|
(Punctuation, ")"),
|
||||||
|
(Text.Whitespace, "\n"),
|
||||||
|
]
|
||||||
|
},
|
||||||
"nested": {
|
"nested": {
|
||||||
'echo @("hello")': [
|
'echo @("hello")': [
|
||||||
(Name.Builtin, "echo"),
|
(Name.Builtin, "echo"),
|
||||||
|
@ -125,20 +178,6 @@ _cases = {
|
||||||
(Text.Whitespace, "\n"),
|
(Text.Whitespace, "\n"),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"subproc-args": {
|
|
||||||
"cd 192.168.0.1": [
|
|
||||||
(Text, "192.168.0.1"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"backtick": {
|
|
||||||
r"echo g`.*\w+`": [
|
|
||||||
(String.Affix, "g"),
|
|
||||||
(String.Backtick, "`"),
|
|
||||||
(String.Regex, "."),
|
|
||||||
(String.Regex, "*"),
|
|
||||||
(String.Escape, r"\w"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"macro": {
|
"macro": {
|
||||||
r"g!(42, *, 65)": [
|
r"g!(42, *, 65)": [
|
||||||
(Name, "g"),
|
(Name, "g"),
|
||||||
|
@ -167,12 +206,23 @@ def _convert_cases():
|
||||||
yield pytest.param(*item, id=f"{title}-{idx}")
|
yield pytest.param(*item, id=f"{title}-{idx}")
|
||||||
|
|
||||||
|
|
||||||
|
def _convert_cases_no_win():
|
||||||
|
for title, input_dict in _cases_no_win.items():
|
||||||
|
for idx, item in enumerate(input_dict.items()):
|
||||||
|
yield pytest.param(*item, id=f"{title}-{idx}")
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("inp, expected", list(_convert_cases()))
|
@pytest.mark.parametrize("inp, expected", list(_convert_cases()))
|
||||||
@skip_if_on_windows
|
|
||||||
def test_xonsh_lexer(inp, expected, check_token):
|
def test_xonsh_lexer(inp, expected, check_token):
|
||||||
check_token(inp, expected)
|
check_token(inp, expected)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("inp, expected", list(_convert_cases_no_win()))
|
||||||
|
@skip_if_on_windows
|
||||||
|
def test_xonsh_lexer_no_win(inp, expected, check_token):
|
||||||
|
check_token(inp, expected)
|
||||||
|
|
||||||
|
|
||||||
# can't seem to get thie test to import pyghooks and define on_lscolors_change handler like live code does.
|
# can't seem to get thie test to import pyghooks and define on_lscolors_change handler like live code does.
|
||||||
# so we declare the event handler directly here.
|
# so we declare the event handler directly here.
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|
Loading…
Add table
Reference in a new issue