summaryrefslogtreecommitdiff
path: root/tests/MPWMake
blob: 7fde8f7f8c52bf66b3658ac77c071a161daeac78 (plain)
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
# Make file for MPW make.
# To run it, use:
#   Make <target> -f MPWMake > Makeout ; Makeout
# where <target> should be replaced with actual make target.

#Possible options:

DOTEST = :utils:DoTest

FPC = ppcppc
#OPT

TEST_FPC = ::compiler:ppcppc
TEST_OS_TARGET = macos
TEST_CPU_TARGET = powerpc
TEST_FULL_TARGET = {TEST_CPU_TARGET}-{TEST_OS_TARGET}
#TEST_OPT
# Target dir where the ppu and binaries are created:
TEST_OUTPUTDIR = :output:{TEST_FULL_TARGET}

TESTSUBDIRS = : :cg: :cg:cdecl: :units:system: :units:dos: :units:crt: :units:objects: :units:strings: :units:sysutils: :units:math:

DIRS = :webtbs: :webtbf: :tbs: :tbf: :test: :test:cg: :test:cg:cdecl: :test:units:system: :test:units:dos: :test:units:crt: :test:units:objects: :test:units:strings: :test:units:sysutils: :test:units:math:

################################
# Utilities
#
:utils:dotest Ä :utils:dotest.pp :utils:redir.pp
	"{FPC}" -WT "{OPT}" -FE:utils: :utils:dotest.pp

:utils:digest Ä :utils:digest.pp
	"{FPC}" -WT "{OPT}" -FE:utils: :utils:digest.pp

:utils:fail Ä :utils:fail.pp
	"{FPC}" -WT "{OPT}" -FE:utils: :utils:fail.pp

:utils:testfail Ä :utils:testfail.pp
	"{FPC}" -WT "{OPT}" -FE:utils: :utils:testfail.pp

utils Ä
	Set Exit 0
	Set isMade ''
	Set isMade :utils:fpcmade.Å > Dev:Null
	Set Exit 1
	If "{isMade}" == ':utils:fpcmade.powerpc-macos'
  	#Echo utils macos made
	Else If "{isMade}" == ''
		#Echo utils not made
		Make utilsbuild -f MPWMake > Makeout2 ; Makeout2
	Else
		#Echo utils made by other
		Make clean_utils -f MPWMake > Makeout2 ; Makeout2		
		Make utilsbuild -f MPWMake > Makeout2 ; Makeout2
	End

utilsbuild Ä :utils:dotest :utils:digest :utils:fail :utils:testfail
	Echo Compiled > :utils:fpcmade.powerpc-macos

################################
# Units
#

units Ä
	Set TEMP_FPC `Files -f "{TEST_FPC}"`
  Directory :units:
	Make all -f MPWMake -d FPC={TEMP_FPC} -d OPT={TEST_OPT} > Makeout ; Makeout
	Directory ::

################################
# Copy test environment dependent files ctest.o to test/cg etc
#

copyfiles Ä {TEST_OUTPUTDIR}
	Duplicate -y :test:cg:obj:{TEST_OS_TARGET}:{TEST_CPU_TARGET}:ctest.o :test:cg
	Set Exit 0
	NewFolder {TEST_OUTPUTDIR}:test
	NewFolder {TEST_OUTPUTDIR}:test:units
	NewFolder {TEST_OUTPUTDIR}:test:units:system
	Set Exit 1
	Duplicate -y :test:units:system:testÅ.txt {TEST_OUTPUTDIR}:test:units:system

################################
# Preparation for tests
#

testprep Ä testprep-stamp.{TEST_FULL_TARGET}

testprep-stamp.{TEST_FULL_TARGET} Ä {TEST_OUTPUTDIR} utils units copyfiles
	Echo `Date` > testprep-stamp.{TEST_FULL_TARGET}

{TEST_OUTPUTDIR} Ä
	Set Exit 0
	NewFolder :output
	NewFolder {TEST_OUTPUTDIR}
	Set Exit 1

################################
# Dotest options
#

################################
# Run tests
#
# Because MPW Make lacks some features, it has to be done as below:
#

allexectest allexectbs allexectbf allexecwebtbs allexecwebtbf Ä testprep
	(Evaluate "{Targ}" =~ /allexec(Å)¨1/) > Dev:Null
	#Assembles, links and run tests of FreePascal
	Set testdir ":{¨1}"
	#Iterate through tests
	If {testdir} == :test
		Set subdirlist "{TESTSUBDIRS}"
	Else
		Set subdirlist :
	End
	Set Exit 0 # To handle the case, in the for stmt, when there is no match
	#
	For subdir In {subdirlist}
		For sourceWithExt In {testdir}{subdir}tÅ.pp  #only test files, which begins with a 't'
			Set Exit 1 #Revert error handling
			#
			(Evaluate "{sourceWithExt}" =~ /(([Â.])*)¨1Å/) > Dev:Null
			Set apppath {¨1}
			(Evaluate "{apppath}" =~ /Å:([Â:]*)¨1/) > Dev:Null
			Set appname {¨1}
			#
			If NOT "`Exists :output:powerpc-macos{apppath}.elg`"
				# Compile and perform the test 
				Echo Testing: "{apppath}"
				:utils:DoTest {DOTESTOPT} -E -X -C{TEST_FPC} "{apppath}.pp"
			End
			Set Exit 0 # To handle the case, in the for stmt, when there is no match
		End
	End
	Set Exit 1 #Revert error handling

allexectests Ä allexectest allexectbs allexectbf allexecwebtbs allexecwebtbf

################################
# Clean
#

clean_test Ä
	Set Exit 0 # To handle the case, when there is no match
	#
	Delete -y -i {TEST_OUTPUTDIR}
	#
	Delete -y -i testÅ.txt Å.tmp core
	#Delete -y  #TODO shared library extension 
	Delete -y -i ppas gmon.out testprep-stamp.*
	Delete -y -i Å_ppas
	#
	Set Exit 1 #Revert error handling

clean Ä clean_test
  Directory :units
	Make clean -f MPWMake > Makeout; Makeout
  Directory ::

clean_utils Ä
	Set Exit 0 # To handle the case, when there is no match
	Delete -y :utils:fpcmade.Å
	Delete -y :utils:dotest :utils:digest :utils:fail :utils:testfail
	Delete -y :utils:Å.o :utils:Å.ppu :utils:Å.xcoff
	Set Exit 1 #Revert error handling

distclean Ä clean clean_utils

cleanall Ä clean clean_utils
#  Directory :utils
#	Make cleanall -f MPWMake > Makeout; Makeout
#  Directory ::

################################
# Main rules
#

digest Ä utils
	:utils:digest {TEST_OUTPUTDIR}:log

all Ä allexectests

full Ä clean allexectests digest