< prev index next >

test/make/TestMakeBase.gmk

Print this page
rev 52919 : 8189861: Refactor CacheFind
Reviewed-by: sgehwolf
rev 52920 : 8223678: Add Visual Studio Code workspace generation support (for native code)
Reviewed-by: andrew, sgehwolf, clanger

@@ -1,7 +1,7 @@
 #
-# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License version 2 only, as
 # published by the Free Software Foundation.  Oracle designates this

@@ -103,17 +103,17 @@
 endif
 
 ################################################################################
 # Test remove-prefixes
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call remove-prefixes, pre, prefix postfix), fix postfix, \
-    Prefixes not properly removed))
+    Prefixes not properly removed)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call remove-prefixes, pre post, prefix postfix), fix fix, \
-    Prefixes not properly removed))
+    Prefixes not properly removed)
 
 ################################################################################
 # Test ShellQuote
 
 SHELL_QUOTE_VALUE := foo '""' "''" bar

@@ -202,23 +202,23 @@
 # Test specifying a specific value file to store variable in
 VARDEP_VALUE_FILE := $(VARDEP_DIR)/value-file
 VARDEP_TEST_VAR2 := value3
 
 VARDEP_RETURN_VALUE := $(call DependOnVariable, VARDEP_TEST_VAR2, $(VARDEP_VALUE_FILE))
-$(eval $(call assert-equals, $(VARDEP_RETURN_VALUE), $(VARDEP_VALUE_FILE), \
-    Wrong filename returned))
+$(call AssertEquals, $(VARDEP_RETURN_VALUE), $(VARDEP_VALUE_FILE), \
+    Wrong filename returned)
 -include $(VARDEP_VALUE_FILE)
-$(eval $(call assert-equals, $(VARDEP_TEST_VAR2_old), $(VARDEP_TEST_VAR2), \
-    Wrong contents in vardeps file))
+$(call AssertEquals, $(VARDEP_TEST_VAR2_old), $(VARDEP_TEST_VAR2), \
+    Wrong contents in vardeps file)
 
 # Test with a variable value containing some problematic characters
 VARDEP_TEST_VAR3 := foo '""' "''" bar \$$ORIGIN &\#x00a9
 VARDEP_VALUE_FILE := $(call DependOnVariable, VARDEP_TEST_VAR3)
 -include $(VARDEP_VALUE_FILE)
-$(eval $(call assert-equals, $(call EscapeHash,$(VARDEP_TEST_VAR3_old)), \
+$(call AssertEquals, $(call EscapeHash,$(VARDEP_TEST_VAR3_old)), \
     $(call EscapeHash,$(VARDEP_TEST_VAR3)), \
-    Wrong contents in vardep file))
+    Wrong contents in vardep file)
 
 TEST_TARGETS += test-vardep
 
 ################################################################################
 # Test sequence

@@ -243,89 +243,102 @@
 ################################################################################
 # Test that PathList is safe when called multiple nested times.
 
 PATHLIST_INPUT := foo bar baz
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call PathList, $(call PathList, $(PATHLIST_INPUT))), \
     $(call PathList, $(PATHLIST_INPUT)), \
-    PathList call not safe for calling twice))
+    PathList call not safe for calling twice, \
+)
 
 ################################################################################
 # Test FindCommonPathPrefix
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar/banan), \
     /foo/bar, \
     FindCommonPathPrefix, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar), \
     /foo/bar, \
     FindCommonPathPrefix, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar/), \
     /foo/bar, \
     FindCommonPathPrefix, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call FindCommonPathPrefix, foo/bar/baz, foo/bar/banan), \
     foo/bar, \
     FindCommonPathPrefix, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call FindCommonPathPrefix, foo/bar/baz, /foo/bar/banan), \
     , \
     FindCommonPathPrefix, \
-))
+)
 
 ################################################################################
 # DirToDotDot
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call DirToDotDot, foo/bar/baz/), \
     ../../.., \
     DirToDotDot, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call DirToDotDot, foo/bar), \
     ../.., \
     DirToDotDot, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call DirToDotDot, /foo), \
     .., \
     DirToDotDot, \
-))
+)
 
 ################################################################################
 # RelativePath
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call RelativePath, foo/bar/baz, foo/bar/banan), \
     ../baz, \
     RelativePath, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call RelativePath, foo/bar/baz/banan/kung, foo/bar/banan/kung), \
     ../../baz/banan/kung, \
     RelativePath, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call RelativePath, /foo/bar/baz/banan/kung, /foo/bar/banan/kung/), \
     ../../baz/banan/kung, \
     RelativePath, \
-))
+)
+
+$(call AssertEquals, \
+    $(call RelativePath, /foo/bar/baz/banan/kung, /foo/bar/baz), \
+    ./banan/kung, \
+    RelativePath, \
+)
+
+$(call AssertEquals, \
+    $(call RelativePath, /foo/bar/baz/banan/kung, /foo/bar/baz/), \
+    ./banan/kung, \
+    RelativePath, \
+)
 
 ################################################################################
 # Test ParseKeywordVariable
 
 KWBASE := APA=banan;GURKA=tomat;COUNT=1%202%203%204%205;SUM=1+2+3+4+5;MANY_WORDS=I have the best words.

@@ -333,53 +346,247 @@
 $(eval $(call ParseKeywordVariable, KWBASE, \
     KEYWORDS := APA GURKA SUM, \
     STRING_KEYWORDS := COUNT MANY_WORDS, \
 ))
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(KWBASE_APA), \
     banan, \
     ParseKeywordVariable failed to parse APA, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(KWBASE_COUNT), \
     1 2 3 4 5, \
     ParseKeywordVariable failed to parse COUNT, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(KWBASE_SUM), \
     1+2+3+4+5, \
     ParseKeywordVariable failed to parse SUM, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(KWBASE_MANY_WORDS), \
     I have the best words., \
     ParseKeywordVariable failed to parse MANY_WORDS, \
-))
+)
 
 # Simulate variable set from command line by using "override"
 override KWBASE_WEIRD_GURKA := paprika
 KWBASE_WEIRD := ;;APA=banan;;;GURKA=apelsin;APA=skansen;;
 
 $(eval $(call ParseKeywordVariable, KWBASE_WEIRD, \
     KEYWORDS := APA GURKA SUM, \
     STRING_KEYWORDS := COUNT, \
 ))
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(KWBASE_WEIRD_APA), \
     skansen, \
     ParseKeywordVariable failed to overwrite APA, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(KWBASE_WEIRD_GURKA), \
     paprika, \
     ParseKeywordVariable failed to preserve GURKA, \
-))
+)
+
+################################################################################
+# Test recursive wildcard
+
+A_FOOBAR := $(OUTPUT_DIR)/wildcard/a/foo.bar
+A_B_DOOBAR := $(OUTPUT_DIR)/wildcard/a/b/doo.bar
+A_B_FOOBAR := $(OUTPUT_DIR)/wildcard/a/b/foo.bar
+A_B_FOOBAZ := $(OUTPUT_DIR)/wildcard/a/b/foo.baz
+X_Y_FOOBAR := $(OUTPUT_DIR)/wildcard/x/y/foo.bar
+X_Y_FOOBAZ := $(OUTPUT_DIR)/wildcard/x/y/foo.baz
+X_Y_FOODOLLAR := $(OUTPUT_DIR)/wildcard/x/y/foo$$foo
+
+$(call MakeDir, $(OUTPUT_DIR)/wildcard/a/b)
+$(call MakeDir, $(OUTPUT_DIR)/wildcard/x/y)
+$(shell $(TOUCH) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_DOOBAR) $(A_B_FOOBAZ) \
+    $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(call ShellQuote, $(X_Y_FOODOLLAR)))
+
+ifeq ($(RWILDCARD_WORKS), true)
+  $(call AssertEquals, \
+      $(sort $(call rwildcard, $(OUTPUT_DIR)/wildcard, *.bar)), \
+      $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_FOOBAR) $(X_Y_FOOBAR)), \
+      Wrong files returned from rwildcard, \
+  )
+
+  $(call AssertEquals, \
+      $(sort $(call rwildcard, $(OUTPUT_DIR)/wildcard, doo.*)), \
+      $(A_B_DOOBAR), \
+      Wrong files returned from rwildcard, \
+  )
+
+  $(call AssertEquals, \
+      $(sort $(call rwildcard, $(OUTPUT_DIR)/wildcard, *.bar *.baz)), \
+      $(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
+      $(X_Y_FOOBAR) $(X_Y_FOOBAZ)), \
+      Wrong files returned from rwildcard, \
+  )
+
+  $(call AssertEquals, \
+      $(sort $(call WildcardFindFiles, $(OUTPUT_DIR)/wildcard)), \
+      $(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
+      $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+      Wrong files returned from WildcardFindFiles, \
+  )
+
+  $(call AssertEquals, \
+      $(sort $(call WildcardFindFiles, $(OUTPUT_DIR)/wildcard/x/y)), \
+      $(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+      Wrong files returned from WildcardFindFiles, \
+  )
+
+  $(call AssertEquals, \
+      $(sort $(call WildcardFindFiles, $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/x)), \
+      $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
+      $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+      Wrong files returned from WildcardFindFiles, \
+  )
+endif
+
+$(call AssertEquals, \
+    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard)), \
+    $(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
+    $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    Wrong files returned from ShellFindFiles, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard/x/y)), \
+    $(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    Wrong files returned from ShellFindFiles, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/x)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
+    $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    Wrong files returned from ShellFindFiles, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard, *.bar)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_FOOBAR) $(X_Y_FOOBAR)), \
+    Wrong files returned from ShellFindFiles, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard, doo.*)), \
+    $(A_B_DOOBAR), \
+    Wrong files returned from ShellFindFiles, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard, *.bar *.baz)), \
+    $(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
+    $(X_Y_FOOBAR) $(X_Y_FOOBAZ)), \
+    Wrong files returned from ShellFindFiles, \
+)
+
+################################################################################
+
+$(call AssertEquals, \
+    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a/b)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ)), \
+    CacheFindFiles test 1, \
+)
+$(call FillFindCache, $(OUTPUT_DIR)/wildcard/a/b)
+$(call AssertEquals, \
+    $(CacheFindFiles_CACHED_DIRS), $(OUTPUT_DIR)/wildcard/a/b, \
+    Wrong files in find cache dirs, \
+)
+$(call AssertEquals, \
+    $(sort $(CacheFindFiles_CACHED_FILES)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ)), \
+    Wrong files in find cache files, \
+)
+$(call AssertEquals, \
+    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a/b)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ)), \
+    CacheFindFiles test 1, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR)), \
+    CacheFindFiles test 2, \
+)
+$(call FillFindCache, $(OUTPUT_DIR)/wildcard/a)
+$(call AssertEquals, \
+    $(CacheFindFiles_CACHED_DIRS), \
+    $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/a, \
+    Wrong files in find cache dirs, \
+)
+$(call AssertEquals, \
+    $(sort $(CacheFindFiles_CACHED_FILES)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR)), \
+    Wrong files in find cache files, \
+)
+$(call AssertEquals, \
+    $(words $(CacheFindFiles_CACHED_FILES)), 4, \
+    Wrong files in find cache files >$(CacheFindFiles_CACHED_FILES)<, \
+)
+$(call AssertEquals, \
+    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR)), \
+    CacheFindFiles test 2, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/x)), \
+    $(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    CacheFindFiles test 3, \
+)
+$(call FillFindCache, $(OUTPUT_DIR)/wildcard/x)
+$(call AssertEquals, \
+    $(CacheFindFiles_CACHED_DIRS), \
+    $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/a $(OUTPUT_DIR)/wildcard/x, \
+    Wrong files in find cache dirs, \
+)
+$(call AssertEquals, \
+    $(sort $(CacheFindFiles_CACHED_FILES)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR) \
+        $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    Wrong files in find cache files, \
+)
+$(call AssertEquals, \
+    $(words $(CacheFindFiles_CACHED_FILES)), 7, \
+    Wrong files in find cache files, \
+)
+$(call AssertEquals, \
+    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/x)), \
+    $(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    CacheFindFiles test 3, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/x/y)), \
+    $(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    CacheFindFiles test 4, \
+)
+$(call FillFindCache, $(OUTPUT_DIR)/wildcard/x/y)
+$(call AssertEquals, \
+    $(CacheFindFiles_CACHED_DIRS), \
+    $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/a $(OUTPUT_DIR)/wildcard/x, \
+    Wrong files in find cache dirs, \
+)
+$(call AssertEquals, \
+    $(sort $(CacheFindFiles_CACHED_FILES)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR) \
+        $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    Wrong files in find cache files, \
+)
+$(call AssertEquals, \
+    $(words $(CacheFindFiles_CACHED_FILES)), 7, \
+    Wrong files in find cache files, \
+)
 
 ################################################################################
 
 all: $(TEST_TARGETS)
< prev index next >