From e309a91ca8d088a60bc7335f4688cc6e8a81b04f Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Wed, 16 Mar 2022 13:42:34 -0700 Subject: Parse variable references with #s Inside a variable reference, a # does not start a comment. Fixes: 218742602 Test: go test Change-Id: I16cf04c74a8aa30482fd9293175f893e4efb60f1 --- androidmk/parser/parser_test.go | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'androidmk/parser/parser_test.go') diff --git a/androidmk/parser/parser_test.go b/androidmk/parser/parser_test.go index f562c29e8..9efebf8e1 100644 --- a/androidmk/parser/parser_test.go +++ b/androidmk/parser/parser_test.go @@ -34,6 +34,56 @@ var parserTestCases = []struct { }, }, }, + { + name: "Simple warning", + in: `$(warning A warning)`, + out: []Node{ + &Variable{ + Name: SimpleMakeString("warning A warning", NoPos), + }, + }, + }, + { + name: "Warning with #", + in: `$(warning # A warning)`, + out: []Node{ + &Variable{ + Name: SimpleMakeString("warning # A warning", NoPos), + }, + }, + }, + { + name: "Findstring with #", + in: `$(findstring x,x a #)`, + out: []Node{ + &Variable{ + Name: SimpleMakeString("findstring x,x a #", NoPos), + }, + }, + }, + { + name: "If statement", + in: `ifeq (a,b) # comment +endif`, + out: []Node{ + &Directive{ + NamePos: NoPos, + Name: "ifeq", + Args: SimpleMakeString("(a,b) ", NoPos), + EndPos: NoPos, + }, + &Comment{ + CommentPos: NoPos, + Comment: " comment", + }, + &Directive{ + NamePos: NoPos, + Name: "endif", + Args: SimpleMakeString("", NoPos), + EndPos: NoPos, + }, + }, + }, } func TestParse(t *testing.T) { -- cgit v1.2.3-59-g8ed1b