mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Merge branch 'master' into NSTimeZone-win32-fix
This commit is contained in:
commit
9a0b660299
15 changed files with 152 additions and 33 deletions
25
ChangeLog
25
ChangeLog
|
@ -6,6 +6,24 @@
|
|||
* Tests/base/NSTimeZone/use.m:
|
||||
Fix test case to check for the correct standard time zone name.
|
||||
|
||||
2022-08-05 Hugo Melder <contact@hugomelder.com>
|
||||
|
||||
* Tests/base/NSTask/Helpers/GNUmakefile:
|
||||
Fix compilation of NSTask helper test files on Windows MSVC.
|
||||
* Tests/base/NSTask/general.m:
|
||||
* Tests/base/NSTask/launch.m:
|
||||
* Tests/base/NSTask/notify.m:
|
||||
Conditionally use .exe suffix in executable paths.
|
||||
|
||||
2022-08-04 Hugo Melder <contact@hugomelder.com>
|
||||
|
||||
* Tests/base/GSTLS/basic.m:
|
||||
Disable test completly if gnutls is not present.
|
||||
* Tests/base/NSData/additions.m:
|
||||
Check if dataWithContentsOfFile: returns an instance.
|
||||
* Tests/base/NSString/tilde.m:
|
||||
Skip tilde abbreviation test on Windows.
|
||||
|
||||
2022-08-04 Hugo Melder <contact@hugomelder.com>
|
||||
|
||||
* Tests/base/coding/basictypes.m:
|
||||
|
@ -13,6 +31,13 @@
|
|||
* .gitignore:
|
||||
Ignore .type files in the coding unit test directory.
|
||||
|
||||
2022-08-03 Hugo Melder <contact@hugomelder.com>
|
||||
|
||||
* Tests/base/NSBundle/GNUmakefile.preamble
|
||||
* Tests/base/NSBundle/resources2.m
|
||||
Exclude framework loading on Windows, as Windows lacks support
|
||||
for run-time search paths.
|
||||
|
||||
2022-07-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSHTTPURLHandle.m:
|
||||
|
|
|
@ -752,6 +752,19 @@ static NSUInteger urlAlign;
|
|||
aUrlString = [aUrlString initWithFormat: @"%@://%@%@",
|
||||
aScheme, aHost, aPath];
|
||||
}
|
||||
#if defined(_WIN32)
|
||||
/* On Windows file systems, an absolute file path can begin with
|
||||
* a drive letter. The first component in an absolute path
|
||||
* (e.g. C:) has to be enclosed by a leading slash.
|
||||
*
|
||||
* "file:///c:/path/to/file"
|
||||
*/
|
||||
else if ([aScheme isEqualToString: @"file"] && [aPath characterAtIndex:1] == ':')
|
||||
{
|
||||
aUrlString = [aUrlString initWithFormat: @"%@:///%@%@",
|
||||
aScheme, aHost, aPath];
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
aUrlString = [aUrlString initWithFormat: @"%@://%@/%@",
|
||||
|
|
|
@ -36,16 +36,15 @@ START_SET("TLS support")
|
|||
#endif
|
||||
[dateFormatter release];
|
||||
PASS_EQUAL([c expiresAt], expiresAt,
|
||||
"Expiration for entire list is that of the single item")
|
||||
#else
|
||||
SKIP("TLS support disabled");
|
||||
#endif
|
||||
|
||||
"Expiration for entire list is that of the single item");
|
||||
|
||||
cred = [GSTLSCredentials selfSigned: YES];
|
||||
NSLog(@"%@", cred);
|
||||
PASS(cred != nil, "generates self signed certificate");
|
||||
|
||||
#else
|
||||
SKIP("TLS support disabled");
|
||||
#endif
|
||||
|
||||
END_SET("TLS support");
|
||||
DESTROY(arp);
|
||||
return 0;
|
||||
|
|
|
@ -16,6 +16,8 @@ int main()
|
|||
GSXMLNode *node;
|
||||
GSXMLRPC *rpc;
|
||||
NSString *str;
|
||||
NSString *testPath;
|
||||
NSString *absolutePath;
|
||||
NSData *dat;
|
||||
|
||||
TEST_FOR_CLASS(@"GSXMLDocument",[GSXMLDocument alloc],
|
||||
|
@ -149,13 +151,16 @@ int main()
|
|||
"Can parse a method call with a date");
|
||||
|
||||
mgr = [NSFileManager defaultManager];
|
||||
testPath = [[mgr currentDirectoryPath]
|
||||
stringByAppendingPathComponent: @"GNUmakefile"];
|
||||
absolutePath = [[NSURL fileURLWithPath: testPath] absoluteString];
|
||||
|
||||
str = [NSString stringWithFormat:
|
||||
@"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
|
||||
@"<!DOCTYPE foo [\n"
|
||||
@"<!ENTITY foo SYSTEM \"file://%@/GNUmakefile\">\n"
|
||||
@"<!ENTITY foo SYSTEM \"%@\">\n"
|
||||
@"]>\n"
|
||||
@"<file>&&foo;A</file>", [mgr currentDirectoryPath]];
|
||||
@"<file>&&foo;A</file>", absolutePath];
|
||||
|
||||
parser = [GSXMLParser parserWithData:
|
||||
[str dataUsingEncoding: NSUTF8StringEncoding]];
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
|
||||
ADDITIONAL_INCLUDE_DIRS += -I../GenericTests/ -I../../..
|
||||
ADDITIONAL_OBJCFLAGS += -Wall
|
||||
|
||||
|
||||
# OR operation to determine whether we are running on Windows, or MinGW.
|
||||
# Windows does not support the concept of a run-time search path.
|
||||
ifneq (,$(filter $(GNUSTEP_TARGET_OS),windows mingw32))
|
||||
else
|
||||
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
|
||||
endif
|
||||
|
||||
$(GNUSTEP_INSTANCE)_SUBPROJECTS = ../GenericTests
|
||||
|
||||
|
|
|
@ -81,9 +81,9 @@ static void _testBundle(NSBundle* bundle, NSString* path, NSString* className)
|
|||
PASS([arr containsObject: localPath],
|
||||
"Returned array for 'German' contains localized resource");
|
||||
Class clz = [bundle classNamed: className];
|
||||
PASS(clz, "Class can be loaded from bundle");
|
||||
PASS(clz != nil, "Class can be loaded from bundle");
|
||||
id obj = [clz new];
|
||||
PASS(obj, "Objects from bundle-loaded classes can be instantiated");
|
||||
PASS(obj != nil, "Objects from bundle-loaded classes can be instantiated");
|
||||
PASS_EQUAL([obj test], @"Something", "Correct method called");
|
||||
[obj release];
|
||||
}
|
||||
|
@ -103,6 +103,9 @@ int main()
|
|||
END_SET("Bundle")
|
||||
|
||||
START_SET("Framework")
|
||||
#if defined(_WIN32)
|
||||
SKIP("Adding a run-time search path is not supported on Windows.")
|
||||
#else
|
||||
/* This method call is required to ensure that the linker does not decide to
|
||||
* elide the framework linkage.
|
||||
*/
|
||||
|
@ -111,6 +114,7 @@ int main()
|
|||
path = [bundle bundlePath];
|
||||
_testBundle(bundle, path, @"TestFramework");
|
||||
PASS(0 == [bundle bundleVersion], "bundleVersion is zero");
|
||||
#endif
|
||||
END_SET("Framework");
|
||||
|
||||
[arp release]; arp = nil;
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
|
||||
START_SET("NSData Additions")
|
||||
#if USE_ZLIB
|
||||
NSData *data;
|
||||
NSData *ref;
|
||||
|
@ -67,6 +69,7 @@ int main()
|
|||
#else
|
||||
SKIP("zlib support disabled");
|
||||
#endif
|
||||
END_SET("NSData Additions")
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
|
|
|
@ -10,27 +10,34 @@ int main()
|
|||
[dict setObject:@"value" forKey:@"key"];
|
||||
NSProgress *progress = [[NSProgress alloc] initWithParent: nil
|
||||
userInfo: dict];
|
||||
PASS(progress != nil, "[NSProgress initWithParent:userInfo:] returns instance");
|
||||
PASS(progress != nil,
|
||||
"[NSProgress initWithParent:userInfo:] returns instance");
|
||||
|
||||
PASS_EQUAL([progress userInfo], dict, @"[NSProgress userInfo] returns correct user info");
|
||||
PASS_EQUAL([progress userInfo], dict,
|
||||
"[NSProgress userInfo] returns correct user info");
|
||||
|
||||
[progress setUserInfoObject:@"new value" forKey:@"key"];
|
||||
PASS_EQUAL([[progress userInfo] objectForKey:@"key"], @"new value", @"[NSProgress setUserInfoObject:forKey:] updates user info");
|
||||
PASS_EQUAL([[progress userInfo] objectForKey:@"key"], @"new value",
|
||||
"[NSProgress setUserInfoObject:forKey:] updates user info");
|
||||
|
||||
progress = [NSProgress discreteProgressWithTotalUnitCount:100];
|
||||
PASS(progress != nil, "[NSProgress discreteProgressWithTotalUnitCount:] returns instance");
|
||||
PASS(progress != nil,
|
||||
"[NSProgress discreteProgressWithTotalUnitCount:] returns instance");
|
||||
|
||||
progress = [NSProgress progressWithTotalUnitCount:100];
|
||||
PASS(progress != nil, "[NSProgress progressWithTotalUnitCount:] returns instance");
|
||||
PASS(progress != nil,
|
||||
"[NSProgress progressWithTotalUnitCount:] returns instance");
|
||||
|
||||
progress = [NSProgress progressWithTotalUnitCount:100
|
||||
parent:progress
|
||||
pendingUnitCount:50];
|
||||
PASS(progress != nil, "[NSProgress progressWithTotalUnitCount:] returns instance");
|
||||
PASS(progress != nil,
|
||||
"[NSProgress progressWithTotalUnitCount:] returns instance");
|
||||
|
||||
[progress becomeCurrentWithPendingUnitCount:50];
|
||||
NSProgress *currentProgress = [NSProgress currentProgress];
|
||||
PASS(currentProgress == progress, "Correct progress object associated with current thread");
|
||||
PASS(currentProgress == progress,
|
||||
"Correct progress object associated with current thread");
|
||||
|
||||
NSProgress *new_progress = [NSProgress progressWithTotalUnitCount:100
|
||||
parent:progress
|
||||
|
@ -40,7 +47,8 @@ int main()
|
|||
|
||||
[currentProgress resignCurrent];
|
||||
|
||||
PASS([NSProgress currentProgress] == nil, "Current progress is nil after resign current");
|
||||
PASS([NSProgress currentProgress] == nil,
|
||||
"Current progress is nil after resign current");
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
|
|
|
@ -32,8 +32,10 @@ int main()
|
|||
PASS_EQUAL([tmp stringByAbbreviatingWithTildeInPath], @"~/Documents/./..",
|
||||
"dot directory reference retained");
|
||||
|
||||
#ifndef _WIN32
|
||||
/* This test can't work on windows, because the ome directory of a
|
||||
#if defined(_WIN32)
|
||||
SKIP("multiple slashes can't be removed on Windows")
|
||||
#else
|
||||
/* This test can't work on windows, because the home directory of a
|
||||
* user doesn't start with a slash... don't run it on _WIN32
|
||||
*/
|
||||
tmp = [NSString stringWithFormat: @"////%@//Documents///", home];
|
||||
|
@ -52,9 +54,12 @@ int main()
|
|||
END_SET("tilde")
|
||||
|
||||
START_SET("tilde abbreviation for other home")
|
||||
|
||||
#if defined(_WIN32)
|
||||
SKIP("tilde abbreviation test not implemented on Windows")
|
||||
#else
|
||||
NSString *home = NSHomeDirectory();
|
||||
NSString *tmp;
|
||||
|
||||
/* The idea here is to use a home directory for a user other than the
|
||||
* current one. We pick root as a user which will exist on most systems.
|
||||
* If the current user is root then this will not work, so we skip the
|
||||
|
@ -71,6 +76,7 @@ int main()
|
|||
}
|
||||
PASS_EQUAL([tmp stringByAbbreviatingWithTildeInPath], tmp,
|
||||
"tilde does nothing for root's home");
|
||||
#endif
|
||||
|
||||
END_SET("tilde abbreviation for other home")
|
||||
return 0;
|
||||
|
|
|
@ -9,7 +9,7 @@ NSZombie_OBJC_FILES = NSZombie.m
|
|||
|
||||
processgroup_OBJC_FILES = processgroup.m
|
||||
|
||||
testcat_OBJC_FILES = testcat.m
|
||||
testcat_C_FILES = testcat.c
|
||||
|
||||
testecho_OBJC_FILES = testecho.m
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ int main()
|
|||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSFileManager *mgr;
|
||||
NSString *helpers;
|
||||
NSString *testecho;
|
||||
NSString *testcat;
|
||||
NSArray *args;
|
||||
id task;
|
||||
id info;
|
||||
|
@ -18,6 +20,16 @@ int main()
|
|||
id pth2;
|
||||
BOOL yes;
|
||||
|
||||
/* Windows MSVC adds the '.exe' suffix to executables
|
||||
*/
|
||||
#if defined(_MSC_VER)
|
||||
testecho = @"testecho.exe";
|
||||
testcat = @"testcat.exe";
|
||||
#else
|
||||
testecho = @"testecho";
|
||||
testcat = @"testcat";
|
||||
#endif
|
||||
|
||||
info = [NSProcessInfo processInfo];
|
||||
env = [[info environment] mutableCopy];
|
||||
yes = YES;
|
||||
|
@ -32,7 +44,8 @@ int main()
|
|||
helpers = [helpers stringByAppendingPathComponent: @"Helpers"];
|
||||
helpers = [helpers stringByAppendingPathComponent: @"obj"];
|
||||
|
||||
pth1 = [helpers stringByAppendingPathComponent: @"testcat"];
|
||||
pth1 = [helpers stringByAppendingPathComponent: testcat];
|
||||
pth2 = [helpers stringByAppendingPathComponent: testecho];
|
||||
|
||||
/* Try some tasks. Make sure the program we use is common between Unix
|
||||
and Windows (and others?) */
|
||||
|
@ -43,7 +56,6 @@ int main()
|
|||
|
||||
task = [NSTask new];
|
||||
args = [NSArray arrayWithObjects: @"xxx", @"yyy", nil];
|
||||
pth2 = [helpers stringByAppendingPathComponent: @"testecho"];
|
||||
[task setEnvironment: env];
|
||||
[task setLaunchPath: pth2];
|
||||
[task setArguments: args];
|
||||
|
|
|
@ -8,15 +8,28 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSTask *task;
|
||||
NSPipe *outPipe;
|
||||
NSFileManager *mgr;
|
||||
NSString *helpers;
|
||||
NSString *testecho;
|
||||
NSString *testcat;
|
||||
NSString *processgroup;
|
||||
NSFileHandle *outHandle;
|
||||
NSAutoreleasePool *arp;
|
||||
NSData *data = nil;
|
||||
|
||||
arp = [[NSAutoreleasePool alloc] init];
|
||||
/* Windows MSVC adds the '.exe' suffix to executables
|
||||
*/
|
||||
#if defined(_MSC_VER)
|
||||
testecho = @"testecho.exe";
|
||||
testcat = @"testcat.exe";
|
||||
processgroup = @"processgroup.exe";
|
||||
#else
|
||||
testecho = @"testecho";
|
||||
testcat = @"testcat";
|
||||
processgroup = @"processgroup";
|
||||
#endif
|
||||
|
||||
mgr = [NSFileManager defaultManager];
|
||||
helpers = [mgr currentDirectoryPath];
|
||||
|
@ -25,7 +38,7 @@ int main()
|
|||
|
||||
task = [[NSTask alloc] init];
|
||||
outPipe = [[NSPipe pipe] retain];
|
||||
[task setLaunchPath: [helpers stringByAppendingPathComponent: @"testcat"]];
|
||||
[task setLaunchPath: [helpers stringByAppendingPathComponent: testcat]];
|
||||
[task setArguments: [NSArray arrayWithObjects: nil]];
|
||||
[task setStandardOutput: outPipe];
|
||||
outHandle = [outPipe fileHandleForReading];
|
||||
|
@ -39,7 +52,7 @@ int main()
|
|||
|
||||
task = [[NSTask alloc] init];
|
||||
outPipe = [[NSPipe pipe] retain];
|
||||
[task setLaunchPath: [helpers stringByAppendingPathComponent: @"testecho"]];
|
||||
[task setLaunchPath: [helpers stringByAppendingPathComponent: testecho]];
|
||||
[task setArguments: [NSArray arrayWithObjects: @"Hello", @"there", nil]];
|
||||
[task setStandardOutput: outPipe];
|
||||
outHandle = [outPipe fileHandleForReading];
|
||||
|
@ -59,7 +72,7 @@ int main()
|
|||
#if !defined(_WIN32)
|
||||
task = [[NSTask alloc] init];
|
||||
[task setLaunchPath:
|
||||
[helpers stringByAppendingPathComponent: @"processgroup"]];
|
||||
[helpers stringByAppendingPathComponent: processgroup]];
|
||||
[task setArguments: [NSArray arrayWithObjects:
|
||||
[NSString stringWithFormat: @"%d", getpgrp()],
|
||||
nil]];
|
||||
|
|
|
@ -32,7 +32,19 @@ static BOOL taskTerminationNotificationReceived;
|
|||
- (void) testNSTaskNotifications
|
||||
{
|
||||
NSDate *deadline;
|
||||
NSString *testsleep;
|
||||
NSString *testecho;
|
||||
BOOL earlyTermination = NO;
|
||||
|
||||
/* Windows MSVC adds the '.exe' suffix to executables
|
||||
*/
|
||||
#if defined(_MSC_VER)
|
||||
testecho = @"testecho.exe";
|
||||
testsleep = @"testsleep.exe";
|
||||
#else
|
||||
testecho = @"testecho";
|
||||
testsleep = @"testsleep";
|
||||
#endif
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
@ -48,7 +60,7 @@ static BOOL taskTerminationNotificationReceived;
|
|||
{
|
||||
BOOL terminated = NO;
|
||||
[task setLaunchPath:
|
||||
[path stringByAppendingPathComponent: @"testsleep"]];
|
||||
[path stringByAppendingPathComponent: testsleep]];
|
||||
[task launch];
|
||||
NSLog(@"Launched pid %d", [task processIdentifier]);
|
||||
NSLog(@"Running run loop for 5 seconds");
|
||||
|
@ -74,7 +86,7 @@ static BOOL taskTerminationNotificationReceived;
|
|||
else
|
||||
{
|
||||
[task setLaunchPath:
|
||||
[path stringByAppendingPathComponent: @"testecho"]];
|
||||
[path stringByAppendingPathComponent: testecho]];
|
||||
[task launch];
|
||||
NSLog(@"Launched pid %d", [task processIdentifier]);
|
||||
NSLog(@"Running run loop for 15 seconds");
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSFileManager.h>
|
||||
#import <Foundation/NSStream.h>
|
||||
#import <Foundation/NSURL.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
#import <Foundation/NSXMLParser.h>
|
||||
#include <string.h>
|
||||
|
@ -256,6 +257,12 @@ testParser(NSXMLParser *parser, NSString *expect)
|
|||
}
|
||||
else
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
/* Replace CRLF from result files with LF
|
||||
*/
|
||||
expect = [expect stringByReplacingOccurrencesOfString: @"\r\n" withString: @"\n"];
|
||||
#endif
|
||||
|
||||
if (NO == [[handler description] isEqual: expect])
|
||||
{
|
||||
NSLog(@"######## Expected:\n%@\n######## Parsed:\n%@\n########\n",
|
||||
|
@ -370,6 +377,8 @@ int main()
|
|||
|
||||
{
|
||||
NSString *exp;
|
||||
NSString *mgrPath;
|
||||
NSString *absolutePath;
|
||||
NSData *dat;
|
||||
|
||||
exp = @"parserDidStartDocument:\n\
|
||||
|
@ -378,10 +387,13 @@ parser:didStartElement:namespaceURI:qualifiedName:attributes: file file {\n}\n\
|
|||
parserDidEndDocument:\n\
|
||||
";
|
||||
|
||||
mgrPath = [[mgr currentDirectoryPath] stringByAppendingPathComponent: @"GNUmakefile"];
|
||||
absolutePath = [[NSURL fileURLWithPath: mgrPath] absoluteString];
|
||||
|
||||
str = [NSString stringWithFormat:
|
||||
@"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
|
||||
@"<!DOCTYPE file [<!ENTITY foo SYSTEM \"file://%@/GNUmakefile\">]>\n"
|
||||
@"<file>&&foo;A</file>", [mgr currentDirectoryPath]];
|
||||
@"<!DOCTYPE file [<!ENTITY foo SYSTEM \"%@\">]>\n"
|
||||
@"<file>&&foo;A</file>", absolutePath];
|
||||
|
||||
dat = [str dataUsingEncoding: NSUTF8StringEncoding];
|
||||
PASS((testParseData(dat, exp, YES)), "external entity (strict)")
|
||||
|
|
Loading…
Reference in a new issue