Comment: | Add ObjFWTest |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
0ceea0145407f449c8fb2d84d589e90e |
User & Date: | js on 2024-02-10 12:55:59 |
Other Links: | manifest | tags |
2024-02-10
| ||
12:57 | • Ticket [183b9d19a8] Testing framework for 3rd party software depending on ObjFW status still Open with 3 other changes artifact: b6f63327a1 user: js | |
2024-02-10
| ||
13:14 | Silence warnings coming from OTAssert.h check-in: f264948665 user: js tags: trunk | |
12:55 | Add ObjFWTest check-in: 0ceea01454 user: js tags: trunk | |
11:30 | ObjFWTest: Add output and show a summary check-in: e94a061758 user: js tags: objfwtest | |
2024-02-06
| ||
20:58 | extra.mk.in: Remove unused variables check-in: b1a90683b9 user: js tags: trunk | |
Modified .fossil-settings/clean-glob from [e3e476a774] to [2a90f48586].
︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist src/runtime/libobjfwrt.* src/tls/Info.plist tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/objc_sync/objc_sync tests/plugin/Info.plist tests/subprocess/subprocess | > > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist src/runtime/libobjfwrt.* src/test/libobjfwtest.a src/tls/Info.plist src/tls/libobjfwtls.* tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/objc_sync/objc_sync tests/plugin/Info.plist tests/subprocess/subprocess |
︙ | ︙ |
Modified .fossil-settings/ignore-glob from [a531885e00] to [1998337625].
︙ | ︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist src/runtime/libobjfwrt.* src/tls/Info.plist tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/iOS.xcodeproj/*.pbxuser tests/iOS.xcodeproj/project.xcworkspace tests/iOS.xcodeproj/xcuserdata | > > | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist src/runtime/libobjfwrt.* src/test/libobjfwtest.a src/tls/Info.plist src/tls/libobjfwtls.* tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/iOS.xcodeproj/*.pbxuser tests/iOS.xcodeproj/project.xcworkspace tests/iOS.xcodeproj/xcuserdata |
︙ | ︙ |
Modified .gitignore from [6d829dc2af] to [f4069ec503].
︙ | ︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist src/runtime/libobjfwrt.* src/tls/Info.plist tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/iOS.xcodeproj/*.pbxuser tests/iOS.xcodeproj/project.xcworkspace tests/iOS.xcodeproj/xcuserdata | > > | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist src/runtime/libobjfwrt.* src/test/libobjfwtest.a src/tls/Info.plist src/tls/libobjfwtls.* tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/iOS.xcodeproj/*.pbxuser tests/iOS.xcodeproj/project.xcworkspace tests/iOS.xcodeproj/xcuserdata |
︙ | ︙ |
Modified src/Makefile from [2a28ea8f9c] to [faa3d6a6cb].
1 2 3 | include ../extra.mk SUBDIRS = ${RUNTIME} exceptions encodings forwarding | | | 1 2 3 4 5 6 7 8 9 10 11 | include ../extra.mk SUBDIRS = ${RUNTIME} exceptions encodings forwarding SUBDIRS_AFTER = ${BRIDGE} ${TLS} test DISTCLEAN = Info.plist objfw-defs.h SHARED_LIB = ${OBJFW_SHARED_LIB} STATIC_LIB = ${OBJFW_STATIC_LIB} FRAMEWORK = ${OBJFW_FRAMEWORK} LIB_MAJOR = ${OBJFW_LIB_MAJOR} LIB_MINOR = ${OBJFW_LIB_MINOR} |
︙ | ︙ |
Added src/test/Makefile version [b269c69e19].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | include ../../extra.mk DISTCLEAN = Info.plist STATIC_LIB = libobjfwtest.a SRCS = OTAssert.m \ OTTestCase.m INCLUDES := ${SRCS:.m=.h} \ ObjFWTest.h SRCS += OTAppDelegate.m \ OTAssertionFailedException.m includesubdir = ObjFWTest include ../../buildsys.mk CPPFLAGS += -I. \ -I.. \ -I../.. \ -I../exceptions \ -I../runtime \ -DOBJFWTEST_LOCAL_INCLUDES LD = ${OBJC} FRAMEWORK_LIBS := -F.. \ -framework ObjFW \ -F../runtime \ ${RUNTIME_FRAMEWORK_LIBS} \ ${LIBS} LIBS := -L.. -lobjfw -L../runtime ${RUNTIME_LIBS} ${LIBS} install-extra: i=ObjFWTest.oc; \ ${INSTALL_STATUS}; \ if ${MKDIR_P} ${libdir}/objfw-config && ${INSTALL} -m 644 $$i ${libdir}/objfw-config/$$i; then \ ${INSTALL_OK}; \ else \ ${INSTALL_FAILED}; \ fi uninstall-extra: i=ObjFWTest.oc; \ if test -f ${libdir}/objfw-config/$$i; then \ if rm -f ${libdir}/objfw-config/$$i; then \ ${DELETE_OK}; \ else \ ${DELETE_FAILED}; \ fi \ fi; \ rmdir ${libdir}/objfw-config >/dev/null 2>&1 || true |
Added src/test/OTAppDelegate.h version [64bf862003].
> > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFApplication.h" OF_ASSUME_NONNULL_BEGIN @interface OTAppDelegate: OFObject <OFApplicationDelegate> @end OF_ASSUME_NONNULL_END |
Added src/test/OTAppDelegate.m version [7058ecd776].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * 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) @implementation OTAppDelegate - (OFSet OF_GENERIC(Class) *)testClasses { Class *classes = objc_copyClassList(NULL); OFMutableSet *testClasses; if (classes == NULL) return nil; @try { testClasses = [OFMutableSet set]; for (Class *iter = classes; *iter != Nil; iter++) if ([*iter isSubclassOfClass: [OTTestCase class]]) [testClasses addObject: *iter]; } @finally { OFFreeMemory(classes); } [testClasses removeObject: [OTTestCase class]]; [testClasses makeImmutable]; return testClasses; } - (OFSet OF_GENERIC(OFValue *) *)testsInClass: (Class)class { Method *methods = class_copyMethodList(class, NULL); OFMutableSet *tests; if (methods == NULL) return nil; @try { tests = [OFMutableSet set]; for (Method *iter = methods; *iter != NULL; iter++) { SEL selector = method_getName(*iter); if (selector == NULL) continue; if (strncmp(sel_getName(selector), "test", 4) == 0) [tests addObject: [OFValue valueWithPointer: selector]]; } } @finally { OFFreeMemory(methods); } [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 fails 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 |
Added src/test/OTAssert.h version [ab93272df2].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #ifdef __clang__ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" #endif #define OTAssert(cond, ...) \ OTAssertImpl(self, _cmd, cond, @#cond, @__FILE__, __LINE__, \ ## __VA_ARGS__, nil) #define OTAssertTrue(cond, ...) OTAssert(cond == true, ## __VA_ARGS__) #define OTAssertFalse(cond, ...) OTAssert(cond == false, ## __VA_ARGS__) #define OTAssertEqual(a, b, ...) OTAssert(a == b, ## __VA_ARGS__) #define OTAssertNotEqual(a, b, ...) OTAssert(a != b, ## __VA_ARGS__) #define OTAssertEqualObjects(a, b, ...) OTAssert([a isEqual: b], ## __VA_ARGS__) #define OTAssertNotEqualObjects(a, b, ...) \ OTAssert(![a isEqual: b], ## __VA_ARGS__) #ifdef __clang__ # pragma clang diagnostic pop #endif #ifdef __cplusplus extern "C" { #endif extern void OTAssertImpl(id testCase, SEL test, bool condition, OFString *check, OFString *file, size_t line, ...); #ifdef __cplusplus } #endif |
Added src/test/OTAssert.m version [dfc3f7ba82].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFString.h" #import "OTAssertionFailedException.h" void OTAssertImpl(id testCase, SEL test, bool condition, OFString *check, OFString *file, size_t line, ...) { va_list arguments; OFConstantString *format; OFString *message = nil; if (condition) return; va_start(arguments, line); format = va_arg(arguments, OFConstantString *); if (format != nil) message = [[[OFString alloc] initWithFormat: format arguments: arguments] autorelease]; va_end(arguments); @throw [OTAssertionFailedException exceptionWithCondition: check message: message]; } |
Added src/test/OTAssertionFailedException.h version [434d5612c9].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFException.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @interface OTAssertionFailedException: OFException { OFString *_condition; OFString *_Nullable _message; } @property (readonly, nonatomic) OFString *condition; @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *message; + (instancetype)exceptionWithCondition: (OFString *)condition message: (nullable OFString *)message; + (instancetype)exception OF_UNAVAILABLE; - (instancetype)initWithCondition: (OFString *)condition message: (nullable OFString *)message; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Added src/test/OTAssertionFailedException.m version [ca30ea25b3].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OTAssertionFailedException.h" @implementation OTAssertionFailedException @synthesize condition = _condition, message = _message; + (instancetype)exceptionWithCondition: (OFString *)condition message: (OFString *)message { return [[[self alloc] initWithCondition: condition message: message] autorelease]; } + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } - (instancetype)initWithCondition: (OFString *)condition message: (OFString *)message { self = [super init]; @try { _condition = [condition copy]; _message = [message copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (void)dealloc { [_condition release]; [_message release]; [super dealloc]; } - (OFString *)description { if (_message != nil) return [OFString stringWithFormat: @"Assertion failed: %@: %@", _condition, _message]; else return [OFString stringWithFormat: @"Assertion failed: %@", _condition]; } @end |
Added src/test/OTTestCase.h version [2add704de5].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #ifdef OBJFWTEST_LOCAL_INCLUDES # import "OFObject.h" #else # import <ObjFW/OFObject.h> #endif OF_ASSUME_NONNULL_BEGIN @interface OTTestCase: OFObject - (void)setUp; - (void)tearDown; @end OF_ASSUME_NONNULL_END |
Added src/test/OTTestCase.m version [3c3d45f200].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OTTestCase.h" @implementation OTTestCase: OFObject - (void)setUp { } - (void)tearDown { } @end |
Added src/test/ObjFWTest.h version [c6fa64803a].
> > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OTTestCase.h" #import "OTAssert.h" |
Added src/test/ObjFWTest.oc version [d1ccd75e86].
> > > | 1 2 3 | package_format 1 LIBS="-lobjfwtest $LIBS" FRAMEWORK_LIBS="-lobjfwtest $FRAMEWORK_LIBS" |