Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests failing on clean checkout #235

Open
pcantrell opened this issue Dec 10, 2020 · 3 comments
Open

Tests failing on clean checkout #235

pcantrell opened this issue Dec 10, 2020 · 3 comments

Comments

@pcantrell
Copy link

When I do a clean checkout of the project and run tests, either with swift test from the command line or in Xcode, I get 6 similar-looking failures:

Test Case '-[MusicXMLTests.HelloWorld testHelloWorldDecoding]' started.
/Users/paul/work/opensource/MusicXML/.build/checkouts/XMLCoder/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift:459: error: -[MusicXMLTests.HelloWorld testHelloWorldDecoding] : failed: caught error: "typeMismatch(MusicXML.PartList.Item, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "part-list", intValue: nil), XMLKey(stringValue: "0", intValue: 0), XMLKey(stringValue: "0", intValue: 0)], debugDescription: "Unrecognized choice", underlyingError: nil))"
Test Case '-[MusicXMLTests.HelloWorld testHelloWorldDecoding]' failed (0.006 seconds).

❌ Partwise/01a-Pitches-Pitches.xml
/Users/paul/work/opensource/MusicXML/Tests/MusicXMLTests/LilyPondTests/LilyPondTestSuite.swift:39: error: -[MusicXMLTests.LilyPondTests testAll] : failed: caught error: "typeMismatch(MusicXML.PartList.Item, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "part-list", intValue: nil), XMLKey(stringValue: "0", intValue: 0), XMLKey(stringValue: "0", intValue: 0)], debugDescription: "Unrecognized choice", underlyingError: nil))"
Test Case '-[MusicXMLTests.LilyPondTests testAll]' failed (0.022 seconds).

/Users/paul/work/opensource/MusicXML/.build/checkouts/XMLCoder/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift:459: error: -[MusicXMLTests.PartNameTests testDecodingPartName] : failed: caught error: "typeMismatch(MusicXML.NameDisplay.Text, Swift.DecodingError.Context(codingPath: [XMLKey(stringValue: "0", intValue: 0), XMLKey(stringValue: "0", intValue: 0)], debugDescription: "Unrecognized choice", underlyingError: nil))"
Test Case '-[MusicXMLTests.PartNameTests testDecodingPartName]' failed (0.001 seconds).

/Users/paul/work/opensource/MusicXML/.build/checkouts/XMLCoder/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift:459: error: -[MusicXMLTests.ReveTests testIdentification] : failed: caught error: "typeMismatch(MusicXML.Encoding.Kind, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "encoding", intValue: nil), XMLKey(stringValue: "0", intValue: 0), XMLKey(stringValue: "0", intValue: 0)], debugDescription: "Unrecognized choice", underlyingError: nil))"
Test Case '-[MusicXMLTests.ReveTests testIdentification]' failed (0.001 seconds).

🎼 Test score: SchbAvMaSample
  Path: /Users/paul/work/opensource/MusicXML/Tests/MusicXMLTests/ScoreTests/MusicXMLSamples/SchbAvMaSample/SchbAvMaSample.musicxml
  Source: https://www.musicxml.com/music-in-musicxml/example-set/
  ❌ Parsing failed: typeMismatch(MusicXML.Encoding.Kind, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "identification", intValue: nil), CodingKeys(stringValue: "encoding", intValue: nil), XMLKey(stringValue: "0", intValue: 0), XMLKey(stringValue: "0", intValue: 0)], debugDescription: "Unrecognized choice", underlyingError: nil))
/Users/paul/work/opensource/MusicXML/Tests/MusicXMLTests/ScoreTests/ScoreTestSuite.swift:79: error: -[MusicXMLTests.ScoreTests testAll] : failed: caught error: "typeMismatch(MusicXML.Encoding.Kind, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "identification", intValue: nil), CodingKeys(stringValue: "encoding", intValue: nil), XMLKey(stringValue: "0", intValue: 0), XMLKey(stringValue: "0", intValue: 0)], debugDescription: "Unrecognized choice", underlyingError: nil))"
Test Case '-[MusicXMLTests.ScoreTests testAll]' failed (0.133 seconds).

/Users/paul/work/opensource/MusicXML/.build/checkouts/XMLCoder/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift:459: error: -[MusicXMLTests.TupletsTremoloTest testTupletsTremolo] : failed: caught error: "typeMismatch(MusicXML.PartList.Item, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "part-list", intValue: nil), XMLKey(stringValue: "0", intValue: 0), XMLKey(stringValue: "0", intValue: 0)], debugDescription: "Unrecognized choice", underlyingError: nil))"
Test Case '-[MusicXMLTests.TupletsTremoloTest testTupletsTremolo]' failed (0.008 seconds).

Is this expected — the current HEAD just in an intermediate state? Or is it a regression with a newer version of Swift, perhaps? I’m using 5.3.1.

@pcantrell
Copy link
Author

The problem appears to stem from the parsing trying to apply XMLChoiceDecodingContainer to XML text elements that contain nothing but whitespace. Stripping all whitespace from between tags in the XML makes at least the HelloWorld test pass.

@pcantrell
Copy link
Author

…and the problem seems to have appeared in this commit whose message is “flag failing test,” so I take it you’re already aware of the problem?

Note that if I set trimValueWhitespaces to false throughout the project, it fixes the issues — but then tests that seem to be explicitly testing for whitespace preservation fail.

@pcantrell
Copy link
Author

More debugging: It works pointing at XMLCoder’s commit that merged @bwetherfield’s CoreOffice/XMLCoder#155, but fails with the next commit in XMLCoder’s history, which merges CoreOffice/XMLCoder#157. It looks like MusicXML had relied on XMLCoder stuffing all the intervening whitespace into the element’s value, as that latter PR describes, and doesn’t know how to skip the newly added intervening text nodes that contain nothing but whitespace.

The internals of the XML parsing are pretty foggy to me, but it looks like one of the following things needs to happen:

  1. MusicXML accounts for and skips blank text nodes.
  2. XMLCoder adds an option distinct from trimValueWhitespaces that drops text nodes that contain only whitespace, but preserves whitespace in text nodes that contain non-whitespace.
  3. MusicXML stops insisting that it preserve leading and trailing whitespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant