drmohundro / SWXMLHash

Simple XML parsing in Swift
MIT License
1.4k stars 203 forks source link

Support Windows #273

Closed compnerd closed 1 year ago

compnerd commented 1 year ago

This set of patches enables building and passing the test suite on Windows. Primarily, treat Windows and Linux similarly. The platform specific behaviour here is the construction of the input paths where we now use URL(fileURLWithPath:) and droppingLastPathComponent and addingPathComponent to compute the location of the test input.

drmohundro commented 1 year ago

🙄 of course the failure would be related to line endings!

Here's one of the failures, but the other is similar:

D:\a\SWXMLHash\SWXMLHash\Tests\SWXMLHashTests\WhiteSpaceParsingTests.swift:55: error: WhiteSpaceParsingTests.testShouldBeAbleToCorrectlyParseCDATASectionsWithWhitespace : XCTAssertEqual failed: 
("Optional("\n        \r\n  this\r\n  has\r\n  white\r\n  space\r\n        \n    ")") is not equal to 
("Optional("\n        \n  this\n  has\n  white\n  space\n        \n    ")")

That should be easy enough to add a platform check around them, though. I can add it to the PR later or you're welcome to if you get to it first.

Thanks for the contribution @compnerd! It looks great!

compnerd commented 1 year ago

I think that the nicer way to handle this is via .gitattributes to ensure that the files are checked out in unix line endings rather than native. That should give us the same behaviour on all the platforms.

drmohundro commented 1 year ago

Good call @compnerd and thanks again!

compnerd commented 1 year ago

My pleasure! One favour to ask - would it be possible to get a tagged release with that by any chance?

drmohundro commented 1 year ago

Absolutely, I just published 7.0.2 out.