diff --git a/.travis.yml b/.travis.yml index 48ab1f20c..b3b750207 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,16 @@ before_install: fi; sudo apt-get install -y libobjc-4.8-dev libblocksruntime-dev; else - sudo apt-get install -y libkqueue-dev libpthread-workqueue-dev; + curl -s -o - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -; + sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main" && sudo apt-get update -qq; + sudo apt-get install -y clang-9 libkqueue-dev libpthread-workqueue-dev; + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-9 10 \ + --slave /usr/bin/clang++ clang++ /usr/bin/clang++-9; + export PATH=$(echo "$PATH" | sed -e 's/:\/usr\/local\/clang-7.0.0\/bin//'); + if [ "$RUNTIME_VERSION" = "gnustep-2.0" ]; + then + sudo update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.gold" 10; + fi; fi; # libdispatch requires a fairly recent version of cmake - > @@ -59,5 +68,5 @@ before_script: > export GNUSTEP_MAKEFILES=$HOME/staging/share/GNUstep/Makefiles; . $HOME/staging/share/GNUstep/Makefiles/GNUstep.sh; script: > - ./configure $BASE_ABI; + ./configure $BASE_ABI || (cat config.log && false); make && make install && make check || (cat Tests/tests.log && false); diff --git a/Tests/base/NSArray/blocks.m b/Tests/base/NSArray/blocks.m index 9112e39d5..ec8a20a9b 100644 --- a/Tests/base/NSArray/blocks.m +++ b/Tests/base/NSArray/blocks.m @@ -4,10 +4,12 @@ #import #import #import +#import #import static NSUInteger fooCount = 0; static NSUInteger lastIndex = NSNotFound; +static BOOL reverse = NO; int main() { START_SET("NSArray Blocks") @@ -16,10 +18,20 @@ int main() # endif # if __has_feature(blocks) NSAutoreleasePool *arp = [NSAutoreleasePool new]; - + NSLock *lock = [[[NSLock alloc] init] autorelease]; NSArray *array = [NSArray arrayWithObjects: @"foo", @"bar", @"foo", nil]; - void(^enumBlock)(id,NSUInteger,BOOL*) = ^(id obj, NSUInteger index, BOOL *stop){ - if ([obj isEqual: @"foo"]){ fooCount++;} lastIndex = index;}; + void(^enumBlock)(id,NSUInteger,BOOL*) = ^(id obj, NSUInteger index, BOOL *stop) { + [lock lock]; + if ([obj isEqual: @"foo"]) { + fooCount++; + } + if (lastIndex == NSNotFound) { + lastIndex = index; + } else { + lastIndex = reverse ? MIN(lastIndex, index) : MAX(lastIndex, index); + } + [lock unlock]; + }; [array enumerateObjectsUsingBlock: enumBlock]; PASS((2 == fooCount) && (lastIndex == 2), "Can forward enumerate array using a block"); @@ -31,9 +43,11 @@ int main() "Can forward enumerate array concurrently using a block"); fooCount = 0; lastIndex = NSNotFound; + reverse = YES; [array enumerateObjectsWithOptions: NSEnumerationReverse usingBlock: enumBlock]; PASS((0 == lastIndex), "Can enumerate array in reverse using a block"); + reverse = NO; fooCount = 0; lastIndex = NSNotFound; enumBlock = ^(id obj, NSUInteger index, BOOL *stop){if ([obj isEqual: @"foo"]){