@@ -158,6 +158,62 @@ ifneq ($(READ_WRITE_VALUE), $(READ_WRITE_RESULT))
158
158
$(error Expected: >$(READ_WRITE_VALUE)< - Result: >$(READ_WRITE_RESULT)<)
159
159
endif
160
160
161
+ TEST_STRING_1 := 1234
162
+ TEST_STRING_2 := 1234$(NEWLINE)
163
+ TEST_STRING_3 := 1234$(NEWLINE)$(NEWLINE)
164
+
165
+ # Writing a string ending in newline should not add a newline, but if it does
166
+ # not, a newline should be added. We check this by verifying that the size of the
167
+ # file is 5 characters for both test strings.
168
+ TEST_FILE_1 := $(OUTPUT_DIR)/write-file-1
169
+ TEST_FILE_2 := $(OUTPUT_DIR)/write-file-2
170
+ TEST_FILE_3 := $(OUTPUT_DIR)/write-file-3
171
+
172
+ $(call WriteFile, $(TEST_STRING_1), $(TEST_FILE_1))
173
+ $(call WriteFile, $(TEST_STRING_2), $(TEST_FILE_2))
174
+ $(call WriteFile, $(TEST_STRING_3), $(TEST_FILE_3))
175
+
176
+ TEST_FILE_1_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_1)))
177
+ TEST_FILE_2_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_2)))
178
+ TEST_FILE_3_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_3)))
179
+
180
+ ifneq ($(TEST_FILE_1_SIZE), 5)
181
+ $(error Expected file size 5 for WriteFile 1, got $(TEST_FILE_1_SIZE))
182
+ endif
183
+ ifneq ($(TEST_FILE_2_SIZE), 5)
184
+ $(error Expected file size 5 for WriteFile 2, got $(TEST_FILE_2_SIZE))
185
+ endif
186
+ ifneq ($(TEST_FILE_3_SIZE), 5)
187
+ $(error Expected file size 5 for WriteFile 3, got $(TEST_FILE_3_SIZE))
188
+ endif
189
+
190
+ # Also test append (assumes WriteFile works as expected)
191
+ $(call WriteFile, $(TEST_STRING_1), $(TEST_FILE_1))
192
+ $(call AppendFile, $(TEST_STRING_1), $(TEST_FILE_1))
193
+ $(call AppendFile, $(TEST_STRING_1), $(TEST_FILE_1))
194
+
195
+ $(call WriteFile, $(TEST_STRING_2), $(TEST_FILE_2))
196
+ $(call AppendFile, $(TEST_STRING_2), $(TEST_FILE_2))
197
+ $(call AppendFile, $(TEST_STRING_2), $(TEST_FILE_2))
198
+
199
+ $(call WriteFile, $(TEST_STRING_3), $(TEST_FILE_3))
200
+ $(call AppendFile, $(TEST_STRING_3), $(TEST_FILE_3))
201
+ $(call AppendFile, $(TEST_STRING_3), $(TEST_FILE_3))
202
+
203
+ TEST_FILE_1_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_1)))
204
+ TEST_FILE_2_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_2)))
205
+ TEST_FILE_3_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_3)))
206
+
207
+ ifneq ($(TEST_FILE_1_SIZE), 15)
208
+ $(error Expected file size 15 for AppendFile 1, got $(TEST_FILE_1_SIZE))
209
+ endif
210
+ ifneq ($(TEST_FILE_2_SIZE), 15)
211
+ $(error Expected file size 15 for AppendFile 2, got $(TEST_FILE_2_SIZE))
212
+ endif
213
+ ifneq ($(TEST_FILE_3_SIZE), 15)
214
+ $(error Expected file size 15 for AppendFile 3, got $(TEST_FILE_3_SIZE))
215
+ endif
216
+
161
217
################################################################################
162
218
# Test creating dependencies on make variables
163
219
0 commit comments