[swift-corelibs-dev] CoreFoundation,SwiftFoundation does compile but not TestFoundation …

2017-12-18 Thread Benoit Pereira da silva via swift-corelibs-dev
Dear Core libs Dev.

I ve found a serious bug on JSONSerialization 
https://bugs.swift.org/browse/SR-6631

I'm trying to build the swift-corelibs-foundation to try to validate a fix.
And i m not able to build the master branch & run the tests.
CoreFoundation,SwiftFoundation does compile but not TestFoundation …

I ve got a `No such module SwiftXCTest` message

M'I missing something?



Benoit Pereira da Silva
Ultra Mobile Developer & Movement Activist
Développeur Ultra Mobile & Militant du mouvement
https://pereira-da-silva.com





✄ 
This e-mail is confidential. Distribution, copy, publication or use of this 
information for any purpose is prohibited without agreement of the sender.
Ce message est confidentiel. Toute distribution, copie, publication ou usage 
des informations contenues dans ce message sont interdits sans agrément 
préalable de l'expéditeur.



___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


[swift-corelibs-dev] Strange behavior the same code fails when building a Cocoa CLI and succeeds in Swift-corelibs-foundation context.

2017-12-18 Thread Benoit Pereira da silva via swift-corelibs-dev
Dear All,


I do encounter a very strange Issue.

I have been adding a test to 
`swift-corelibs-foundation/testJSONSerialization.swift`
This test succeed within swift-corelibs-foundation test, but fails when 
repackaged to a Cocoa CLI app.

The  swift-corelibs-foundation test : 


func test_serializeFloatingPointWithANonDotDecimalSeparatorLocale() {
// We use a locale that is using "," as decimal separator.
setlocale(LC_ALL,"fr_FR")

let dictionary = ["decimalValue":1.1]
do{
let data = try JSONSerialization.data(withJSONObject: dictionary)
if let json =  String(data:data, encoding:.utf8){
XCTAssert(!json.contains(","), "Expected result: 
\"{\"decimalValue\":1.1001}\" found: \"\(json)\"" )
}else{
XCTFail("Failed during string encoding")
}
}catch{
XCTFail("Failed during serialization")
}
}


The simple CLI code that proves the bug (https://bugs.swift.org/browse/SR-6631 
)

//
//  main.swift
//  doubleEncoding
//
//  Created by Benoit Pereira da silva on 02/12/2017.
//  Copyright © 2017 Pereira da Silva. All rights reserved.
//

import Foundation

// Let's set to french
setlocale(LC_ALL,"fr_FR")

do{
let dictionary = ["decimalValue":1.1]
let data = try JSONSerialization.data(withJSONObject: dictionary)
if let json =  String(data:data, encoding:.utf8){
// the result is : "{"decimalValue":1,1001}"
// The decimal separator should not be "," but "."
print(json)
}
}catch{
print("\(error)")
}



Any idea ?
I do use Toolchain: Swift Development Snapshot 2017-12-17 (a)


Benoit



Benoit Pereira da Silva
Ultra Mobile Developer & Movement Activist
Développeur Ultra Mobile & Militant du mouvement
https://pereira-da-silva.com 





✄ 
This e-mail is confidential. Distribution, copy, publication or use of this 
information for any purpose is prohibited without agreement of the sender.
Ce message est confidentiel. Toute distribution, copie, publication ou usage 
des informations contenues dans ce message sont interdits sans agrément 
préalable de l'expéditeur.



___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


Re: [swift-corelibs-dev] Strange behavior the same code fails when building a Cocoa CLI and succeeds in Swift-corelibs-foundation context.

2017-12-18 Thread Benoit Pereira da silva via swift-corelibs-dev
Thanks Philippe,


> Good find, 
> You can make a pull request and we can get our continuous integration servers 
> to start building that and testing your change – that is probably the easiest 
> way to get validation on your tests and changes.
> There are a few issues however with your test that might be worth 
> considering. Comments inline…
… 
> Building a CLI tool will use the objective-c Foundation in the system so that 
> wont use your freshly built swift-corelibs-foundation. So that means we have 
> a bug in the objc side if this is actually happening on Darwin (which is a 
> completely different issue…) That should be a radar against Foundation and I 
> definitely think that may very well be a bug… 


I have been filling a radar https://bugreport.apple.com/web/?problemID=36107307 

I do think you are right it's a bug in the Objc Foundation… and trying to solve 
it in "swift-corelibs-foundation" was a mistake :) 


>> setlocale(LC_ALL,"fr_FR”)
> 
> This change will set the locale globally for the rest of the process, you 
> probably want to make sure to reset the locale back to it’s original state.


Setting the locale globally was just a temporary test.

But i do think that it triggers a serious question:  Should all your tests be 
ran on all the available locales? 
You will certainly find a smarter solution …

Benoit



___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


Re: [swift-corelibs-dev] Strange behavior the same code fails when building a Cocoa CLI and succeeds in Swift-corelibs-foundation context.

2017-12-18 Thread Benoit Pereira da silva via swift-corelibs-dev


>> But i do think that it triggers a serious question:  Should all your tests 
>> be ran on all the available locales? 
>> You will certainly find a smarter solution …
> 
> I think it is sensible to iterate through a key list of known locales that 
> have certain characteristics, such as using the , as a decimal separator or « 
> for quote begin etc (not to pick on French but it is the one I know better 
> than other punctuation differentials from English).
> 
> There are probably key areas that are worth doing this to and others that 
> probably do not matter so much. e.g. you don’t really need to test locale 
> variations with NotificationCenter for example whereas NumberFormatter or 
> JSONSerialization may be places that we want to test a few locales by 
> subclassing the unit tests and in setup change the locale and teardown reset 
> it.


Philippe,

Being subtile is not always the best approach. 
Are we really able to determinate where such a problem may occur?  Should we 
even try? 
I’m not  sure !

Smarts approaches may lead to enabling a root account with a blank password. 
Running tests on any locale on every commit is absurd. 

But running it before a major release, may enable to detect blind spots.


B 



___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


[swift-corelibs-dev] That's Confirmed The JSON foundation Bug SR-6631, is a Bug in Darwin's Objc Foundations.

2017-12-19 Thread Benoit Pereira da silva via swift-corelibs-dev
Dear All,


Philippe Hausler has emitted the hypothesis that 
https://bugs.swift.org/browse/SR-6631 was a bug in Darwin Objc Foundations.
He was right! Shall i close the Swift SR-6631? 

The following Objc Implementation is faulting:

 #import 

int main(int argc, const char * argv[]) {
@autoreleasepool {
// Let's set to french
setlocale(LC_ALL,"fr_FR");
NSDictionary *dictionary = @{@"decimalValue":@1.1};
NSError* error = nil;
NSData* data = [NSJSONSerialization dataWithJSONObject:dictionary 
options:kNilOptions error:&error];
NSString * json = [[NSString alloc] initWithData:data 
encoding:NSUTF8StringEncoding];
NSLog(@"%@",json);
}
return 0;
}


Result :  2017-12-19 09:08:49.657316+0100 doubleEncodingObjc[2016:82301] 
{"decimalValue":1,1001}



I’have been updating the relevant radar: 
https://bugreport.apple.com/web/?problemID=36107307



Benoit



Benoit Pereira da Silva
Ultra Mobile Developer & Movement Activist
Développeur Ultra Mobile & Militant du mouvement
https://pereira-da-silva.com 





✄ 
This e-mail is confidential. Distribution, copy, publication or use of this 
information for any purpose is prohibited without agreement of the sender.
Ce message est confidentiel. Toute distribution, copie, publication ou usage 
des informations contenues dans ce message sont interdits sans agrément 
préalable de l'expéditeur.



___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


[swift-corelibs-dev] How to crash swift core libs foundation tests ? By Setting a locale before executing test suite

2017-12-22 Thread Benoit Pereira da silva via swift-corelibs-dev
Dear Core Devs, 


There is a vicious bug in Darwin’s Objc implementation of JSON number encoding 
that irritates the president Macron :) this fact is well established. (check 
SR-6631  for details) 
But there is more, i've found an interesting variante that demonstrates that an 
equivalent issue exists in the Swift Core Foundations.

How to reproduce some correlated issues in swift-corelibs-foundation ? 

1- write `setlocale(LC_ALL,"fr_FR »)` in 
`swift-corelibs-foundation/TestFoundation/main.swift`
2- Run the tests. => The unit tests will crash. 
https://clients.pereira-da-silva.com/apple/core-lib-test-crash.png 


Setting a locale globally before running tests is not a normal procedure, but i 
do maintain that all critical test suites should be tested against a bunch of 
Locales to determinate possible localization impact.
I think that running at least all the tests suites once with various locales 
would enable to determinate if there are other blind spots.
When those spot will be clearly located we could apply a systematic multi local 
testing procedure to specific code areas to reduce the tests loads.

Best regards,

PS: @chris, you are in copy of this mail because  i would appreciate to have 
your opinion on a what  general testing strategy we could apply to prevent 
internationalization blind spot issues.




Benoit Pereira da Silva
Ultra Mobile Developer & Movement Activist
Développeur Ultra Mobile & Militant du mouvement
https://pereira-da-silva.com





✄ 
This e-mail is confidential. Distribution, copy, publication or use of this 
information for any purpose is prohibited without agreement of the sender.
Ce message est confidentiel. Toute distribution, copie, publication ou usage 
des informations contenues dans ce message sont interdits sans agrément 
préalable de l'expéditeur.



___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev