ObjFW  Diff

Differences From Artifact [d77755a8a2]:

To Artifact [7aa90ae52e]:


13
14
15
16
17
18
19

20

21
22
23
24
25
26
27
 * file.
 */

#include "config.h"

#import "OTAppDelegate.h"


#import "OFSet.h"

#import "OFValue.h"

#import "OTTestCase.h"

#import "OTAssertionFailedException.h"

OF_APPLICATION_DELEGATE(OTAppDelegate)







>

>







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 * file.
 */

#include "config.h"

#import "OTAppDelegate.h"

#import "OFColor.h"
#import "OFSet.h"
#import "OFStdIOStream.h"
#import "OFValue.h"

#import "OTTestCase.h"

#import "OTAssertionFailedException.h"

OF_APPLICATION_DELEGATE(OTAppDelegate)
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
	[tests makeImmutable];
	return tests;
}

- (void)applicationDidFinishLaunching: (OFNotification *)notification
{
	OFSet OF_GENERIC(Class) *testClasses = [self testClasses];





	for (Class class in testClasses) {


		for (OFValue *test in [self testsInClass: class]) {
			void *pool = objc_autoreleasePoolPush();

			OTTestCase *instance =






			    [[[class alloc] init] autorelease];

			@try {
				[instance setUp];
				[instance performSelector: test.pointerValue];
			} @catch (OTAssertionFailedException *e) {
				/*
				 * If an assertion during -[setUp], don't run
				 * the test.
				 * If an assertion fails during a test, abort
				 * the test.
				 */







			}
			@try {
				[instance tearDown];
			} @catch (OTAssertionFailedException *e) {
				/*
				 * If an assertion fails during -[tearDown],
				 * abort the tear down.
				 */








			}
















			objc_autoreleasePoolPop(pool);
		}
	}




	[OFApplication terminate];
}
@end







>

>
>
>

>
>


>
|
>
>
>
>
>
>
|











>
>
>
>
>
>
>








>
>
>
>
>
>
>
>
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>



>
>
>




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
	[tests makeImmutable];
	return tests;
}

- (void)applicationDidFinishLaunching: (OFNotification *)notification
{
	OFSet OF_GENERIC(Class) *testClasses = [self testClasses];
	size_t numSucceeded = 0, numFailed = 0;

	[OFStdOut writeFormat: @"Running %zu test case(s)\n",
			       testClasses.count];

	for (Class class in testClasses) {
		[OFStdOut writeFormat: @"Running tests in %@\n", class];

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

			[OFStdOut setForegroundColor: [OFColor yellow]];
			[OFStdOut writeFormat:
			    @"-[%@ %s]: ",
			    class, sel_getName(test.pointerValue)];

			instance = [[[class alloc] init] autorelease];

			@try {
				[instance setUp];
				[instance performSelector: test.pointerValue];
			} @catch (OTAssertionFailedException *e) {
				/*
				 * If an assertion during -[setUp], don't run
				 * the test.
				 * If an assertion fails during a test, abort
				 * the test.
				 */
				[OFStdOut setForegroundColor: [OFColor red]];
				[OFStdOut writeFormat:
				    @"\r-[%@ %s]: failed\n",
				    class, sel_getName(test.pointerValue)];
				[OFStdOut writeLine: e.description];

				failed = true;
			}
			@try {
				[instance tearDown];
			} @catch (OTAssertionFailedException *e) {
				/*
				 * If an assertion fails during -[tearDown],
				 * abort the tear down.
				 */
				if (!failed) {
					[OFStdOut setForegroundColor:
					    [OFColor red]];
					[OFStdOut writeFormat:
					    @"\r-[%@ %s]: failed\n",
					    class,
					    sel_getName(test.pointerValue)];
					[OFStdOut writeLine: e.description];

					failed = true;
				}
			}

			if (!failed) {
				[OFStdOut setForegroundColor: [OFColor green]];
				[OFStdOut writeFormat:
				    @"\r-[%@ %s]: ok\n",
				    class, sel_getName(test.pointerValue)];

				numSucceeded++;
			} else
				numFailed++;

			[OFStdOut reset];

			objc_autoreleasePoolPop(pool);
		}
	}

	[OFStdOut writeFormat: @"%zu test(s) succeeded, %zu test(s) failed.\n",
			       numSucceeded, numFailed];

	[OFApplication terminate];
}
@end