This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Makefile
193 lines (159 loc) · 6.09 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
.PHONY: help
help:
@echo "(this is 'make help')"
@echo "## BUILDING ##"
@echo ""
@echo "make build"
@echo " Just build."
@echo "make clean"
@echo " Nuke all build byproducts."
@echo "make install-into-gaia"
@echo " Clean, build and copy tests into gaia"
@echo ""
@echo "## FAKE SERVERS (for use by you, not for testing) ##"
@echo ""
@echo "make imap-server"
@echo " Run the IMAP fake-server"
@echo "make activesync-server"
@echo " Run the ActiveSync fake-server"
@echo ""
@echo "## USEFUL STUFF ##"
@echo ""
@echo "make autoconfig DOMAIN=example.com"
@echo ""
@echo "## TESTING ##"
@echo ""
@echo "make tests"
@echo " Run all tests"
@echo "make results"
@echo " View detailed test results in a browser"
@echo ""
@echo "make one-test SOLO_FILE=test_name.js"
@echo " Run one test file (all variants)"
@echo "make one-test SOLO_FILE=test_name.js TEST_VARIANT=imap:fake"
@echo " Run one test file (imap:fake variant)"
@echo ""
@echo "make gdb-one-test SOLO_FILE=test_name.js TEST_VARIANT=imap:fake"
@echo " Run one test file under gdb. Set breakpoints, type 'run'"
@echo ""
@echo "To enable verbose log output to the console: TEST_LOG_ENABLE=true"
TEST_VARIANT ?= all
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
OUR_JS_DEPS := $(rwildcard js/*.js)
install-into-gaia: clean build gaia-symlink $(OUR_JS_DEPS)
rsync --delete -arv --exclude='.git' \
--exclude='.gitignore' \
--exclude='.gitmodules' \
--exclude='.jshintrc' \
--exclude='Gruntfile.js' \
--exclude='LICENSE' \
--exclude='Makefile' \
--exclude='NOTICE' \
--exclude='package.json' \
--exclude='README.*' \
--exclude='examples' \
--exclude='test' \
--exclude='ext/rdplat' \
js/ gaia-symlink/apps/email/js/ext/
build: $(OUR_JS_DEPS)
git submodule update --init --recursive
node scripts/sync-js-ext-deps.js
.PHONY: download-b2g
download-b2g: b2g
gaia-symlink:
echo "You need to create a symlink 'gaia-symlink' pointing at the gaia dir"
SYS=$(shell uname -s)
B2GBD := b2g-builddir-symlink
ifeq ($(wildcard b2g-bindir-symlink),)
B2GBIND := $(B2GBD)/dist/bin
RUNB2G := $(B2GBIND)/b2g
else
# OS X has trouble launching the executable via the symlink, gets a "Couldn't
# load XPCOM" error, so resolve the symlink first. Do not generically use
# readlink on all platforms, since it behaves slightly differently, and only
# the OS X platform seems to exhibit this problem.
ifeq ($(SYS),Darwin)
B2GBIND=`readlink b2g-bindir-symlink`
else
B2GBIND := b2g-bindir-symlink
endif
RUNB2G := $(B2GBIND)/b2g-bin
endif
# Best effort use RUNMOZ if its available otherwise ignore it.
RUNMOZ := $(wildcard $(B2GBIND)/run-mozilla.sh)
# Common test running logic. Some test files are for both IMAP and ActiveSync.
# Some test files are just for one or the other. xpcshell has a mechanism for
# specifying constraings on test files in xpcshell.ini, and we are using that.
SOLO_FILE ?= $(error Specify a test filename in SOLO_FILE when using check-interactive or check-one)
TESTRUNNER=$(CURDIR)/test/loggest-runner.js
# run all the tests listed in a test config file
define run-tests # $(call run-tests)
-rm -rf test-profile
-mkdir -p test-profile/device-storage test-profile/fake-sdcard
-$(RUNMOZ) $(RUNMOZFLAGS) $(RUNB2G) -app $(CURDIR)/test-runner/application.ini -no-remote -profile $(CURDIR)/test-profile --test-config $(CURDIR)/test/test-files.json --test-variant $(TEST_VARIANT) --test-log-enable "$(TEST_LOG_ENABLE)"
endef
# run one test
define run-one-test
-rm -rf test-profile
-mkdir -p test-profile/device-storage test-profile/fake-sdcard
-$(RUNMOZ) $(RUNMOZFLAGS) $(RUNB2G) -app $(CURDIR)/test-runner/application.ini -no-remote -profile $(CURDIR)/test-profile --test-config $(CURDIR)/test/test-files.json --test-name $(SOLO_FILE) --test-variant $(TEST_VARIANT) --test-log-enable "$(TEST_LOG_ENABLE)"
endef
define run-no-test
-rm -rf $(2)
-mkdir -p $(2)/device-storage $(2)/fake-sdcard
-$(RUNMOZ) $(RUNMOZFLAGS) $(RUNB2G) -app $(CURDIR)/test-runner/application.ini -no-remote -profile $(CURDIR)/$(2) --test-config $(CURDIR)/test/test-files.json --test-command "$(1)" --test-log-enable "true" --test-arg "$(3)"
endef
######################
# All tests
.PHONY: test-deps
test-deps: node_modules
-mkdir -p logic-inspector/test-logs
-ln -s logic-inspector/test-logs
-cd logic-inspector; make
# If our package.json has been updated, run npm install
node_modules: package.json
npm install
touch node_modules
tests: build test-deps
$(call run-tests)
one-test: build test-deps
$(call run-one-test)
# wrap one-test with gdb flags to RUNMOZ. Abstraction so I don't have to
# remember this and because when we shift to using mach or such then it can
# be a transparent change, etc.
gdb-one-test: RUNMOZFLAGS=-g
# turn off the JIT's auto-segfault magic.
gdb-one-test: export JS_NO_SIGNALS=1
gdb-one-test: export JS_DISABLE_SLOW_SCRIPT_SIGNALS=1
gdb-one-test: one-test
post-one-test: one-test
post-tests: tests
######################
# Bundle up all the tests!
all-tests: tests
ACTIVESYNC_SERVER_PORT ?= 8880
FAKE_ACTIVESYNC_PROFILE=fake-activesync-server-profile
activesync-server:
$(call run-no-test,activesync-fake-server,$(FAKE_ACTIVESYNC_PROFILE))
FAKE_IMAP_PROFILE=fake-imap-server-profile
imap-server:
$(call run-no-test,imap-fake-server,$(FAKE_IMAP_PROFILE))
DOMAIN ?= $(error You need to specify DOMAIN=thedomain.duh when using autoconfig)
GENERIC_RUN_PROFILE=generic-profile
autoconfig:
$(call run-no-test,autoconfig,$(GENERIC_RUN_PROFILE),$(DOMAIN))
.PHONY: results
results:
xdg-open logic-inspector/index.html &> /dev/null || open logic-inspector/index.html &> /dev/null
clean:
rm -rf data/deps
rm -rf node-transformed-deps
-rm test-logs/*.json
.DEFAULT_GOAL=help
.PHONY: build install-into-gaia
b2g: node_modules
./node_modules/.bin/mozilla-download \
--product b2g-desktop \
--branch mozilla-central \
./
ln -nsf ./b2g b2g-bindir-symlink