Merge pull request #107 from gnustep/framework_test

Extend NSBundle test to check for framework resource loading.
This commit is contained in:
Fred Kiefer 2020-03-09 08:41:33 +01:00 committed by GitHub
commit 1de4c85f43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 10 deletions

View file

@ -1,3 +1,10 @@
2020-03-01 Fred Kiefer <fredkiefer@gmx.de>
* Tests/base/NSBundle/TestInfo,
* Tests/base/NSBundle/GNUmakefile.preamble,
* Tests/base/NSBundle/resources2.m: Extend test to check for
framework resource loading.
2020-03-06 Richard Frith-Macdonald <rfm@gnu.org>
* Resources/Languages/Locale.canonical:

View file

@ -1,6 +1,9 @@
ADDITIONAL_INCLUDE_DIRS += -I../GenericTests/ -I../../..
ADDITIONAL_OBJCFLAGS += -Wall
resources2_LDFLAGS += -Wl,-rpath -Wl,$(CURDIR)/Resources/TestFramework.framework/Versions/Current/$(GNUSTEP_TARGET_LDIR)
resources2_LIB_DIRS += -L./Resources/TestFramework.framework/$(GNUSTEP_TARGET_LDIR)
resources2_TOOL_LIBS += -lTestFramework
$(GNUSTEP_INSTANCE)_SUBPROJECTS = ../GenericTests

View file

@ -16,7 +16,7 @@ TestFramework_OBJC_FILES = TestFramework.m
TestFramework_RESOURCE_FILES = NonLocalRes.txt
TestFramework_LANGUAGES = English French de
TestFramework_LOCALIZED_RESOURCE_FILES = TextRes.txt
TestFramework_CURRENT_VERSION_NAME = 2
include $(GNUSTEP_MAKEFILES)/bundle.make
include $(GNUSTEP_MAKEFILES)/framework.make

View file

@ -10,16 +10,18 @@
- (NSString*)test;
@end
@interface TestFramework: NSObject
@end
static void _testBundle(NSString* name, NSString* className)
static void _testBundle(NSBundle* bundle, NSString* path, NSString* className)
{
NSBundle *bundle;
NSArray *arr, *carr;
NSString *path, *localPath;
path = [[[[[NSFileManager defaultManager] currentDirectoryPath]
stringByStandardizingPath] stringByAppendingPathComponent: @"Resources"]
stringByAppendingPathComponent: name];
bundle = [NSBundle bundleWithPath: path];
NSString *localPath;
PASS((bundle != nil),
"bundle was found");
PASS((path != nil),
"path of bundle was found");
arr = [bundle pathsForResourcesOfType: @"txt" inDirectory: nil];
PASS((arr && [arr count]),
"-pathsForResourcesOfType:inDirectory: returns an array");
@ -89,12 +91,28 @@ static void _testBundle(NSString* name, NSString* className)
int main()
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSString *path;
NSBundle *bundle;
START_SET("Bundle")
_testBundle(@"TestBundle.bundle", @"TestBundle");
path = [[[[[NSFileManager defaultManager] currentDirectoryPath]
stringByStandardizingPath] stringByAppendingPathComponent: @"Resources"]
stringByAppendingPathComponent: @"TestBundle.bundle"];
bundle = [NSBundle bundleWithPath: path];
_testBundle(bundle, path, @"TestBundle");
END_SET("Bundle")
START_SET("Framework")
_testBundle(@"TestFramework.framework", @"TestFramework");
/* This method call is required to ensure that the linker does not decide to
* elide the framework linkage.
*/
[TestFramework class];
bundle = [NSBundle bundleForClass: NSClassFromString(@"TestFramework")];
path = [bundle bundlePath];
_testBundle(bundle, path, @"TestFramework");
PASS(0 == [bundle bundleVersion], "bundleVersion is zero");
END_SET("Framework");
[arp release]; arp = nil;
return 0;
}