forked from jeanlego/CS2263_Summer2019_A1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
105 lines (82 loc) · 3.58 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
#########################################
# Created by Jean-Philippe Legault
#
# This is a comment, a comment always start with `#`
# Indentation is primordial in a Makefile.
# the steps for a target are always indented
#
##########################################
# compile with gcc, change this to clang if you prefer
COMPILER = gcc
# The C flags to pass to gcc
C_FLAGS = -Wall -Wextra
# prepend the command with '@' so that Make does not print the command before running it
help:
@printf "available command:\n"
@printf " make help (this command)\n"
@printf " make Stack (to build your C program)\n"
@printf " make test (to run every test case)\n"
@printf " make exit_test (to run test cases against the exit instruction for your program)\n"
@printf " make push_test (to run test cases against the push instruction for your program)\n"
@printf " make peek_test (to run test cases against the peek instruction for your program)\n"
@printf " make pop_test (to run test cases against the pop instruction for your program)\n"
@printf " make compound_test (to run test cases against all the instruction for your program)\n"
# link our .o files to make an executable
Stack: Stack.o
$(COMPILER) $(C_FLAGS) -o Stack Stack.o
# compile the `Stack.o` file
Stack.o: Stack.c
$(COMPILER) $(C_FLAGS) -c Stack.c
##################################################################
# Test Cases
test: exit_test push_test peek_test pop_test compound_test
##############################
# exit test cases
exit_test: exit_test1
# run our executable by passing in the text file via stdin with `<` and passing stdout to a file with `>`
# then use a scrit to verify that the result are the same one as the one expected
exit_test1: Stack
./Stack < Data/exit_test1.input > exit_test1.result
./TestPassed.sh exit_test1.result Data/exit_test1.expected
##############################
# push test cases
push_test: push_test1 push_test2
push_test1: Stack
./Stack < Data/push_test1.input > push_test1.result
./TestPassed.sh push_test1.result Data/push_test1.expected
push_test2: Stack
./Stack < Data/push_test2.input > push_test2.result
./TestPassed.sh push_test2.result Data/push_test2.expected
##############################
# peek test cases
peek_test: peek_test1 peek_test2
peek_test1: Stack
./Stack < Data/peek_test1.input > peek_test1.result
./TestPassed.sh peek_test1.result Data/peek_test1.expected
peek_test2: Stack
./Stack < Data/peek_test2.input > peek_test2.result
./TestPassed.sh peek_test2.result Data/peek_test2.expected
##############################
# pop test cases
pop_test: pop_test1 pop_test2 pop_test3
pop_test1: Stack
./Stack < Data/pop_test1.input > pop_test1.result
./TestPassed.sh pop_test1.result Data/pop_test1.expected
pop_test2: Stack
./Stack < Data/pop_test2.input > pop_test2.result
./TestPassed.sh pop_test2.result Data/pop_test2.expected
pop_test3: Stack
./Stack < Data/pop_test3.input > pop_test3.result
./TestPassed.sh pop_test3.result Data/pop_test3.expected
##############################
# compound test cases
compound_test: compound_test1 compound_test2 compound_test3
compound_test1: Stack
./Stack < Data/compound_test1.input > compound_test1.result
./TestPassed.sh compound_test1.result Data/compound_test1.expected
compound_test2: Stack
./Stack < Data/compound_test2.input > compound_test2.result
./TestPassed.sh compound_test2.result Data/compound_test2.expected
compound_test3: Stack
./Stack < Data/compound_test3.input > compound_test3.result
./TestPassed.sh compound_test3.result Data/compound_test3.expected