ObjFW  Diff

Differences From Artifact [0d0dad0a14]:

  • File src/test/OTAppDelegate.m — part of check-in [9d802a786d] at 2025-01-01 12:58:18 on branch trunk — Update copyright (user: js size: 15150) [more...]

To Artifact [65ae9ded9e]:

  • File src/test/OTAppDelegate.m — part of check-in [b940c60230] at 2025-01-07 23:05:59 on branch trunk — OFStdIOStream: Keep track of colors (user: js size: 15034)

214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
		   inClass: (Class)class
		    status: (enum Status)status
	       description: (OFString *)description
{
	switch (status) {
	case StatusRunning:
		if (OFStdOut.hasTerminal) {
			[OFStdOut setForegroundColor: [OFColor olive]];
			[OFStdOut writeFormat: @"-[%@ ", class];
			[OFStdOut setForegroundColor: [OFColor yellow]];
			[OFStdOut writeFormat: @"%s", sel_getName(test)];
			[OFStdOut setForegroundColor: [OFColor olive]];
			[OFStdOut writeString: @"]: "];
		} else
			[OFStdOut writeFormat: @"-[%@ %s]: ",
					       class, sel_getName(test)];
		break;
	case StatusOk:
		if (OFStdOut.hasTerminal) {
			[OFStdOut setCursorColumn: 0];
			[OFStdOut eraseLine];
			[OFStdOut setForegroundColor: [OFColor green]];
			[OFStdOut writeFormat: @"-[%@ ", class];
			[OFStdOut setForegroundColor: [OFColor lime]];
			[OFStdOut writeFormat: @"%s", sel_getName(test)];
			[OFStdOut setForegroundColor: [OFColor green]];
			[OFStdOut writeLine: @"]: ok"];
		} else
			[OFStdOut writeLine: @"ok"];
		break;
	case StatusFailed:
		if (OFStdOut.hasTerminal) {
			[OFStdOut setCursorColumn: 0];
			[OFStdOut eraseLine];
			[OFStdOut setForegroundColor: [OFColor maroon]];
			[OFStdOut writeFormat: @"-[%@ ", class];
			[OFStdOut setForegroundColor: [OFColor red]];
			[OFStdOut writeFormat: @"%s", sel_getName(test)];
			[OFStdOut setForegroundColor: [OFColor maroon]];
			[OFStdOut writeLine: @"]: failed"];
		} else
			[OFStdOut writeLine: @"failed"];

		if (description != nil)
			[OFStdOut writeLine: description];

		break;
	case StatusSkipped:
		if (OFStdOut.hasTerminal) {
			[OFStdOut setCursorColumn: 0];
			[OFStdOut eraseLine];
			[OFStdOut setForegroundColor: [OFColor gray]];
			[OFStdOut writeFormat: @"-[%@ ", class];
			[OFStdOut setForegroundColor: [OFColor silver]];
			[OFStdOut writeFormat: @"%s", sel_getName(test)];
			[OFStdOut setForegroundColor: [OFColor gray]];
			[OFStdOut writeLine: @"]: skipped"];
		} else
			[OFStdOut writeLine: @"skipped"];

		if (description != nil)
			[OFStdOut writeLine: description];

		break;
	}

	if (status == StatusFailed) {
#if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS) || \
    defined(OF_NINTENDO_SWITCH)
		[OFStdOut setForegroundColor: [OFColor silver]];
		[OFStdOut writeLine: @"Press A to continue"];

# ifdef OF_NINTENDO_SWITCH
		while (appletMainLoop()) {
# else
		for (;;) {
# endif







|

|

|









|

|

|








|

|

|












|

|

|













|







214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
		   inClass: (Class)class
		    status: (enum Status)status
	       description: (OFString *)description
{
	switch (status) {
	case StatusRunning:
		if (OFStdOut.hasTerminal) {
			OFStdOut.foregroundColor = [OFColor olive];
			[OFStdOut writeFormat: @"-[%@ ", class];
			OFStdOut.foregroundColor = [OFColor yellow];
			[OFStdOut writeFormat: @"%s", sel_getName(test)];
			OFStdOut.foregroundColor = [OFColor olive];
			[OFStdOut writeString: @"]: "];
		} else
			[OFStdOut writeFormat: @"-[%@ %s]: ",
					       class, sel_getName(test)];
		break;
	case StatusOk:
		if (OFStdOut.hasTerminal) {
			[OFStdOut setCursorColumn: 0];
			[OFStdOut eraseLine];
			OFStdOut.foregroundColor = [OFColor green];
			[OFStdOut writeFormat: @"-[%@ ", class];
			OFStdOut.foregroundColor = [OFColor lime];
			[OFStdOut writeFormat: @"%s", sel_getName(test)];
			OFStdOut.foregroundColor = [OFColor green];
			[OFStdOut writeLine: @"]: ok"];
		} else
			[OFStdOut writeLine: @"ok"];
		break;
	case StatusFailed:
		if (OFStdOut.hasTerminal) {
			[OFStdOut setCursorColumn: 0];
			[OFStdOut eraseLine];
			OFStdOut.foregroundColor = [OFColor maroon];
			[OFStdOut writeFormat: @"-[%@ ", class];
			OFStdOut.foregroundColor = [OFColor red];
			[OFStdOut writeFormat: @"%s", sel_getName(test)];
			OFStdOut.foregroundColor = [OFColor maroon];
			[OFStdOut writeLine: @"]: failed"];
		} else
			[OFStdOut writeLine: @"failed"];

		if (description != nil)
			[OFStdOut writeLine: description];

		break;
	case StatusSkipped:
		if (OFStdOut.hasTerminal) {
			[OFStdOut setCursorColumn: 0];
			[OFStdOut eraseLine];
			OFStdOut.foregroundColor = [OFColor gray];
			[OFStdOut writeFormat: @"-[%@ ", class];
			OFStdOut.foregroundColor = [OFColor silver];
			[OFStdOut writeFormat: @"%s", sel_getName(test)];
			OFStdOut.foregroundColor = [OFColor gray];
			[OFStdOut writeLine: @"]: skipped"];
		} else
			[OFStdOut writeLine: @"skipped"];

		if (description != nil)
			[OFStdOut writeLine: description];

		break;
	}

	if (status == StatusFailed) {
#if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS) || \
    defined(OF_NINTENDO_SWITCH)
		OFStdOut.foregroundColor = [OFColor silver];
		[OFStdOut writeLine: @"Press A to continue"];

# ifdef OF_NINTENDO_SWITCH
		while (appletMainLoop()) {
# else
		for (;;) {
# endif
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
			}

			[testClasses addObject: class];
		}
	} else
		testClasses = [self testClasses];

	[OFStdOut setForegroundColor: [OFColor purple]];
	[OFStdOut writeString: @"Running "];
	[OFStdOut setForegroundColor: [OFColor fuchsia]];
	[OFStdOut writeFormat: @"%zu", testClasses.count];
	[OFStdOut setForegroundColor: [OFColor purple]];
	[OFStdOut writeFormat: @" test case%s\n",
			       (testClasses.count != 1 ? "s" : "")];

	for (Class class in testClasses) {
		OFArray *summary;

		[OFStdOut setForegroundColor: [OFColor teal]];
		[OFStdOut writeFormat: @"Running ", class];
		[OFStdOut setForegroundColor: [OFColor aqua]];
		[OFStdOut writeFormat: @"%@\n", class];

		for (OFValue *test in [self testsInClass: class]) {
			void *pool = objc_autoreleasePoolPush();
			bool failed = false, skipped = false;
			OTTestCase *instance;








|

|

|






|

|







383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
			}

			[testClasses addObject: class];
		}
	} else
		testClasses = [self testClasses];

	OFStdOut.foregroundColor = [OFColor purple];
	[OFStdOut writeString: @"Running "];
	OFStdOut.foregroundColor = [OFColor fuchsia];
	[OFStdOut writeFormat: @"%zu", testClasses.count];
	OFStdOut.foregroundColor = [OFColor purple];
	[OFStdOut writeFormat: @" test case%s\n",
			       (testClasses.count != 1 ? "s" : "")];

	for (Class class in testClasses) {
		OFArray *summary;

		OFStdOut.foregroundColor = [OFColor teal];
		[OFStdOut writeFormat: @"Running ", class];
		OFStdOut.foregroundColor = [OFColor aqua];
		[OFStdOut writeFormat: @"%@\n", class];

		for (OFValue *test in [self testsInClass: class]) {
			void *pool = objc_autoreleasePoolPush();
			bool failed = false, skipped = false;
			OTTestCase *instance;

499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
		if (summary != nil)
			[summaries setObject: summary forKey: class];
	}

	for (Class class in summaries) {
		OFArray *summary = [summaries objectForKey: class];

		[OFStdOut setForegroundColor: [OFColor teal]];
		[OFStdOut writeString: @"Summary for "];
		[OFStdOut setForegroundColor: [OFColor aqua]];
		[OFStdOut writeFormat: @"%@\n", class];

		for (OFPair *line in summary) {
			[OFStdOut setForegroundColor: [OFColor navy]];
			[OFStdOut writeFormat: @"%@: ", line.firstObject];
			[OFStdOut setForegroundColor: [OFColor blue]];
			[OFStdOut writeFormat: @"%@\n", line.secondObject];
		}
	}

	[OFStdOut setForegroundColor: [OFColor fuchsia]];
	[OFStdOut writeFormat: @"%zu", numSucceeded];
	[OFStdOut setForegroundColor: [OFColor purple]];
	[OFStdOut writeFormat: @" test%s succeeded, ",
			       (numSucceeded != 1 ? "s" : "")];
	[OFStdOut setForegroundColor: [OFColor fuchsia]];
	[OFStdOut writeFormat: @"%zu", numFailed];
	[OFStdOut setForegroundColor: [OFColor purple]];
	[OFStdOut writeFormat: @" test%s failed, ",
			       (numFailed != 1 ? "s" : "")];
	[OFStdOut setForegroundColor: [OFColor fuchsia]];
	[OFStdOut writeFormat: @"%zu", numSkipped];
	[OFStdOut setForegroundColor: [OFColor purple]];
	[OFStdOut writeFormat: @" test%s skipped\n",
			       (numSkipped != 1 ? "s" : "")];
	[OFStdOut reset];

#if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS)
	[OFStdOut setForegroundColor: [OFColor silver]];
# ifdef OF_WII
	[OFStdOut writeLine: @"Press Home button to exit"];
# else
	[OFStdOut writeLine: @"Press Start button to exit"];
# endif

	for (;;) {







|

|



|

|




|

|


|

|


|

|





|







499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
		if (summary != nil)
			[summaries setObject: summary forKey: class];
	}

	for (Class class in summaries) {
		OFArray *summary = [summaries objectForKey: class];

		OFStdOut.foregroundColor = [OFColor teal];
		[OFStdOut writeString: @"Summary for "];
		OFStdOut.foregroundColor = [OFColor aqua];
		[OFStdOut writeFormat: @"%@\n", class];

		for (OFPair *line in summary) {
			OFStdOut.foregroundColor = [OFColor navy];
			[OFStdOut writeFormat: @"%@: ", line.firstObject];
			OFStdOut.foregroundColor = [OFColor blue];
			[OFStdOut writeFormat: @"%@\n", line.secondObject];
		}
	}

	OFStdOut.foregroundColor = [OFColor fuchsia];
	[OFStdOut writeFormat: @"%zu", numSucceeded];
	OFStdOut.foregroundColor = [OFColor purple];
	[OFStdOut writeFormat: @" test%s succeeded, ",
			       (numSucceeded != 1 ? "s" : "")];
	OFStdOut.foregroundColor = [OFColor fuchsia];
	[OFStdOut writeFormat: @"%zu", numFailed];
	OFStdOut.foregroundColor = [OFColor purple];
	[OFStdOut writeFormat: @" test%s failed, ",
			       (numFailed != 1 ? "s" : "")];
	OFStdOut.foregroundColor = [OFColor fuchsia];
	[OFStdOut writeFormat: @"%zu", numSkipped];
	OFStdOut.foregroundColor = [OFColor purple];
	[OFStdOut writeFormat: @" test%s skipped\n",
			       (numSkipped != 1 ? "s" : "")];
	[OFStdOut reset];

#if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS)
	OFStdOut.foregroundColor = [OFColor silver];
# ifdef OF_WII
	[OFStdOut writeLine: @"Press Home button to exit"];
# else
	[OFStdOut writeLine: @"Press Start button to exit"];
# endif

	for (;;) {