From e9cc403553a2886a608a59c24f2ee7aab12946fd Mon Sep 17 00:00:00 2001 From: Min Yun Date: Tue, 3 Sep 2024 20:36:47 +0900 Subject: Fix End() of Rule If a directive appears in the middle of a Rule, the Rule does not reflect its length. This must be reflected to obtain the correct End() position of the Rule. Change-Id: I67a78f95487829c639b0c1414ac4cc096faa6363 --- androidmk/parser/parser_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'androidmk/parser/parser_test.go') diff --git a/androidmk/parser/parser_test.go b/androidmk/parser/parser_test.go index fb03c2324..e238f8b11 100644 --- a/androidmk/parser/parser_test.go +++ b/androidmk/parser/parser_test.go @@ -124,3 +124,25 @@ func TestParse(t *testing.T) { }) } } + +func TestRuleEnd(t *testing.T) { + name := "ruleEndTest" + in := `all: +ifeq (A, A) + echo foo + echo foo + echo foo + echo foo +endif + echo bar +` + p := NewParser(name, bytes.NewBufferString(in)) + got, errs := p.Parse() + if len(errs) != 0 { + t.Fatalf("Unexpected errors while parsing: %v", errs) + } + + if got[0].End() < got[len(got) -1].Pos() { + t.Errorf("Rule's end (%d) is smaller than directive that inside of rule's start (%v)\n", got[0].End(), got[len(got) -1].Pos()) + } +} -- cgit v1.2.3-59-g8ed1b