'swift test' sometimes fails with 'error: malformed'

I've seen this cryptic error before, which as you note, comes from the Swift compiler. Try running the tests in verbose mode by adding the -v flag, that will give you more info.

SwiftPM should be modified to never pass along that cryptic compiler error message alone. Right, @NeoNacho?