Skip to content

Commit

Permalink
test(make): add test cases for GitHub #544
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 22, 2022
1 parent a392580 commit b352d4c
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/fixtures/make/test2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# makefile

all: abc/xyz
.PHONY: abc/xyz
abc/xyz 123/xaa 123/xbb:
mkdir -p $(@:/%=)
date > $@

sub1test/bar/alpha sub1test/bar/beta:
mkdir -p $(@:/%=)
date > $@

sub2test/bar/alpha:
mkdir -p $(@:/%=)
date > $@

sub3test/bar/alpha sub3test/foo/alpha:
mkdir -p $(@:/%=)
date > $@

sub4test/bar/alpha sub4test/bar/beta sub4test2/foo/gamma:
mkdir -p $(@:/%=)
date > $@
37 changes: 37 additions & 0 deletions test/t/test_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import pytest

from conftest import assert_complete


class TestMake:
@pytest.mark.complete("make -f Ma", cwd="make")
Expand Down Expand Up @@ -45,3 +47,38 @@ def test_8(self, bash, completion):
@pytest.mark.complete("make -", require_cmd=True)
def test_9(self, completion):
assert completion


@pytest.mark.bashcomp(require_cmd=True, cwd="make/test2")
class TestMake2:
def test_github_issue_544_1(self, bash):
completion = assert_complete(bash, "make ab")
assert completion == "c/xyz"

def test_github_issue_544_2(self, bash):
completion = assert_complete(bash, "make 1")
assert completion == "23/"

def test_github_issue_544_3(self, bash):
completion = assert_complete(bash, "make 123/")
assert completion == ["xaa", "xbb"]

def test_github_issue_544_4(self, bash):
completion = assert_complete(bash, "make 123/xa")
assert completion == "a"

def test_subdir_1(self, bash):
completion = assert_complete(bash, "make sub1")
assert completion == "test/bar/"

def test_subdir_2(self, bash):
completion = assert_complete(bash, "make sub2")
assert completion == "test/bar/alpha"

def test_subdir_3(self, bash):
completion = assert_complete(bash, "make sub3")
assert completion == "test/"

def test_subdir_4(self, bash):
completion = assert_complete(bash, "make sub4")
assert completion == "sub4test/bar/ sub4test2/foo/gamma".split()

0 comments on commit b352d4c

Please sign in to comment.