forked from sodascourse/hw-test-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (53 loc) · 1.87 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
err = (printf "\n\033[0;31mERROR: %s\033[0m\n\n" $(1) && exit 1)
check-var = (test `wc -w <<< $(1)` != "0" || $(call err,"\`$(2)\` is required."))
usage:
#
# Usage
#
# make homework1 path=<SOURCE_DIR> scheme=<XCODE_SCHEME>
#
check-path:
#
# >> Make sure path argument has been set
#
$(call check-var,"${path}","path")
check-scheme:
#
# >> Make sure path argument has been set
#
$(call check-var,"${scheme}","scheme")
# Dependency -----------------------------------------------------------------------------------------------------------
install:
#
# >> Install dependent packages if necessary
#
gem list -i bundler 1>/dev/null 2>&1 || gem install bundle
bundle check 1>/dev/null 2>&1 || bundle install
# Git ------------------------------------------------------------------------------------------------------------------
check-git-clean: check-path
#
# >> Make Sure git repo is clean
#
test `cd ${path} && git status --porcelain | wc -l` == "0" || $(call err,"git is not clean")
clean-git: check-path
#
# >> Clean git repository
#
cd ${path} && git checkout -- .
# Inject ---------------------------------------------------------------------------------------------------------------
INJECT-UI:=bundle exec ruby lib/inject-uitest.rb ${path} ${scheme}
TEST_CASE_HW1?=hw1-calculator-test/
inject-homework1: check-path check-scheme check-git-clean install
#
# >> Inject UITests for homework1
#
$(INJECT-UI) $(TEST_CASE_HW1)
# Run ------------------------------------------------------------------------------------------------------------------
run-test: check-scheme check-path install
#
# >> Run Tests
#
cd ${path} && scan -s ${scheme} --clean -o /dev/null
# Interface ------------------------------------------------------------------------------------------------------------
HOMEWORKS=homework1 homework2
$(HOMEWORKS): % : inject-% run-test clean-git