From 64630aaeca0a5013e4b438577138f0f707c68cb1 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sun, 20 Jun 2021 11:00:54 +0900 Subject: [PATCH] test(make): add test cases for GitHub #544 --- test/fixtures/make/test2/Makefile | 23 +++++++++++++++++++ test/t/test_make.py | 37 +++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 test/fixtures/make/test2/Makefile diff --git a/test/fixtures/make/test2/Makefile b/test/fixtures/make/test2/Makefile new file mode 100644 index 00000000000..835b51440e2 --- /dev/null +++ b/test/fixtures/make/test2/Makefile @@ -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 > $@ diff --git a/test/t/test_make.py b/test/t/test_make.py index aaf5fead14d..74efb4a9a35 100644 --- a/test/t/test_make.py +++ b/test/t/test_make.py @@ -2,6 +2,8 @@ import pytest +from conftest import assert_complete + class TestMake: @pytest.mark.complete("make -f Ma", cwd="make") @@ -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()