Separate unit test Makefile commands to separate variables for readability.
Also add more debug info for the make.
This commit is contained in:
parent
43b57f9e49
commit
58a2919ef7
@ -1,47 +1,79 @@
|
||||
# Create temporary profile directory name.
|
||||
TEMP_PROFILE_DIR:=./test_reports/temp_profile
|
||||
TEMP_PROFILE:=./test_reports/temp_profile
|
||||
|
||||
# These are the Firefox command line arguments.
|
||||
FIREFOX_ARGS:=-no-remote -profile $(TEMP_PROFILE_DIR)
|
||||
FIREFOX_ARGS:=-no-remote -profile $(TEMP_PROFILE)
|
||||
|
||||
# These are the Chrome command line arguments.
|
||||
CHROME_ARGS:=--user-data-dir=$(TEMP_PROFILE_DIR) --no-first-run --disable-sync
|
||||
CHROME_ARGS:=--user-data-dir=$(TEMP_PROFILE) --no-first-run --disable-sync
|
||||
|
||||
# Unit test uses the manifest from ref test to determine which browsers will
|
||||
# be used for running the unit tests.
|
||||
MANIFEST:=../resources/browser_manifests/browser_manifest.json
|
||||
|
||||
# This is a helper function to separate multiple browsers to their own lines
|
||||
# for an easier sed operation.
|
||||
SPLIT_LINES:=sed 's|,|,\n|g'
|
||||
|
||||
# This is a helper function to join multiple lines together.
|
||||
JOIN_LINES:=tr -d '\n'
|
||||
|
||||
# Fetch the paths to browsers that are going to be used in testing.
|
||||
# For OS X the path to the binary needs to be added.
|
||||
# Add the browser arguments for each browser.
|
||||
# Create random profile directory for each browser.
|
||||
# Replace " with @@@@ so that echoing do not destroy the quotation marks.
|
||||
BROWSERS_WITH_UKNOWN_RANDOM_PROFILE_PATHS:=$(shell echo `\
|
||||
BROWSERS_PATHS:=$(shell echo `\
|
||||
sed -n 's|.*"path":\(.*\)|\1,|p' $(MANIFEST) | \
|
||||
$(JOIN_LINES) \
|
||||
`)
|
||||
|
||||
# The browser_manifest.json file has only the app directory for mac browsers.
|
||||
# The absolute path to the browser binary needs to be used.
|
||||
BROWSERS_PATHS_WITH_MAC_CORRECTION:=$(shell echo '$(BROWSERS_PATHS)' | \
|
||||
$(SPLIT_LINES) | \
|
||||
sed 's|\(Aurora\.app\)|\1/Contents/MacOS/firefox-bin|' | \
|
||||
sed 's|\(Firefox.*\.app\)|\1/Contents/MacOS/firefox-bin|' | \
|
||||
sed 's|\(Google Chrome\.app\)|\1/Contents/MacOS/Google Chrome|' | \
|
||||
sed "s|\(irefox.*\)\",|\1;$(FIREFOX_ARGS)\",|" | \
|
||||
sed "s|\(hrome.*\)\",|\1;$(CHROME_ARGS)\",|" | \
|
||||
$(JOIN_LINES) \
|
||||
)
|
||||
|
||||
# Replace " with @@@@ so that echoing do not destroy the quotation marks.
|
||||
QUOTATION_MARK:=\"
|
||||
SUBSTITUTE_FOR_QUOTATION_MARK:=@@@@
|
||||
|
||||
# Each of the browser can have their ow separate arguments.
|
||||
BROWSERS_WITH_ARGUMENTS:=$(shell echo '$(BROWSERS_PATHS_WITH_MAC_CORRECTION)' | \
|
||||
$(SPLIT_LINES) | \
|
||||
sed "s|\(irefox.*\)\($(QUOTATION_MARK)\),|\1;$(FIREFOX_ARGS)\2,|" | \
|
||||
sed "s|\(hrome.*\)\($(QUOTATION_MARK)\),|\1;$(CHROME_ARGS)\2,|" | \
|
||||
$(JOIN_LINES) \
|
||||
)
|
||||
|
||||
# A temporary profile directory is needed for each of the browser. In this way
|
||||
# a unit test run will not disturb the main browsing session of the user. The
|
||||
# $RANDOM shell variable is used to generate non-conflicting temporary
|
||||
# directories.
|
||||
BROWSERS_WITH_UKNOWN_RANDOM_PROFILE_PATHS:=$(shell echo '$(BROWSERS_WITH_ARGUMENTS)' | \
|
||||
$(SPLIT_LINES) | \
|
||||
sed 's|\(temp_profile\)|\1_$$(echo $$RANDOM$$RANDOM)|' | \
|
||||
sed 's|"|@@@@|g' | \
|
||||
tr -d '\n' \
|
||||
`)
|
||||
sed "s|$(QUOTATION_MARK)|$(SUBSTITUTE_FOR_QUOTATION_MARK)|g" | \
|
||||
$(JOIN_LINES) \
|
||||
)
|
||||
|
||||
# Echo the variable so that the unknown random directories become known.
|
||||
# Replace @@@@ with " so that jsTestDriver will work properly.
|
||||
BROWSERS:=$(shell echo "$(BROWSERS_WITH_UKNOWN_RANDOM_PROFILE_PATHS)" | \
|
||||
sed 's|@@@@|"|g' \
|
||||
sed "s|$(SUBSTITUTE_FOR_QUOTATION_MARK)|$(QUOTATION_MARK)|g" \
|
||||
)
|
||||
|
||||
# Split the browsers to separate lines.
|
||||
# Get the known random directories for browsers. This information will be used
|
||||
# to create the profile directories beforehand.
|
||||
# Join the separate lines back together.
|
||||
PROFILES:=$(shell echo $(BROWSERS) | \
|
||||
sed 's|,|\n|g' | \
|
||||
# to create the profile directories beforehand. Create also the dummy temp
|
||||
# profile directory so that the mkdir command would not fail for browsers that
|
||||
# do not need it.
|
||||
PROFILES:=$(TEMP_PROFILE) $(shell echo '$(BROWSERS)' | \
|
||||
$(SPLIT_LINES) | \
|
||||
sed -n "s|.*\(\..*_[0-9]\+\).*|\1 |p" | \
|
||||
tr -d '\n' \
|
||||
$(JOIN_LINES) \
|
||||
)
|
||||
|
||||
# This is the command to invoke the unit test.
|
||||
@ -57,7 +89,13 @@ PROG:=java \
|
||||
--testOutput ./test_reports/
|
||||
|
||||
test:
|
||||
@echo 'Debug random profile paths: $(BROWSERS_WITH_UKNOWN_RANDOM_PROFILE_PATHS)'
|
||||
@echo 'Debug browsers paths: $(BROWSERS_PATHS)'
|
||||
@echo
|
||||
@echo 'Debug browsers paths with mac correction: $(BROWSERS_PATHS_WITH_MAC_CORRECTION)'
|
||||
@echo
|
||||
@echo 'Debug browsers with arguments: $(BROWSERS_WITH_ARGUMENTS)'
|
||||
@echo
|
||||
@echo 'Debug browsers random profile paths: $(BROWSERS_WITH_UKNOWN_RANDOM_PROFILE_PATHS)'
|
||||
@echo
|
||||
@echo 'Debug browsers: $(BROWSERS)'
|
||||
@echo
|
||||
|
Loading…
Reference in New Issue
Block a user