test/make/TestCopyFiles.gmk
author chegar
Wed, 08 Nov 2017 12:44:07 +0000
branchhttp-client-branch
changeset 55782 0586f8664ba8
parent 47334 09d386ddaa42
child 47751 f7e430cbfe34
permissions -rw-r--r--
http-client-branch: merge with default

#
# Copyright (c) 2017, 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
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

default: all

include $(SPEC)
include MakeBase.gmk
include UtilsForTests.gmk

THIS_FILE := $(TOPDIR)/test/make/TestCopyFiles.gmk
DEPS := $(THIS_FILE) \
    $(TOPDIR)/make/common/MakeBase.gmk \
    #

OUTPUT_DIR := $(TESTMAKE_OUTPUTDIR)/copy-files
$(call MakeDir, $(OUTPUT_DIR))

################################################################################
# Test SetupCopyFiles with CacheFind and files with spaces in their names.

SRC_DIR := $(OUTPUT_DIR)/src
DEST_DIR := $(OUTPUT_DIR)/dest

$(OUTPUT_DIR)/_src_created: $(DEPS)
	$(RM) -r $(SRC_DIR)
	$(MKDIR) -p $(SRC_DIR)
	$(MKDIR) -p $(SRC_DIR)/foo
	$(TOUCH) $(SRC_DIR)/file
	$(TOUCH) $(SRC_DIR)/foo/foofile
	$(TOUCH) "$(SRC_DIR)/foo/foo file"
        # Spaces in directories only works with gnu make 4.0 or later
        ifeq (4.0, $(firstword $(sort 4.0 $(MAKE_VERSION))))
	  $(MKDIR) -p "$(SRC_DIR)/foo bar"
	  $(TOUCH) "$(SRC_DIR)/foo bar/foobarfile"
	  $(TOUCH) "$(SRC_DIR)/foo bar/foo bar file"
        endif
	$(LN) -s file "$(SRC_DIR)/link to file"
	$(TOUCH) $@

$(eval $(call SetupCopyFiles, COPY_1, \
    SRC := $(SRC_DIR), \
    DEST := $(DEST_DIR), \
    FILES := $(call CacheFind, $(SRC_DIR)), \
))

do-copy1: $(COPY_1)

run-test1: $(OUTPUT_DIR)/_src_created
	+$(MAKE) -f $(THIS_FILE) do-copy1
	$(DIFF) -r $(SRC_DIR) $(DEST_DIR)

TEST_TARGETS += run-test1

.PHONY: do-copy1 run-test1

################################################################################

all: $(TEST_TARGETS)