muter-mutation-testing / muter

🔎 Automated mutation testing for Swift 🕳️
MIT License
491 stars 39 forks source link

Error: Could not parse buildRequest.json from build description path #250

Closed Nikoloutsos closed 4 months ago

Nikoloutsos commented 8 months ago

Hello decided to give this testing technique a shot in my project and I got the following error. If anyone has any idea how to debug/solve it would be awesome 🙏

Error log:

+-----------------+
Analyzing source files to find mutants which can be inserted into your project...
In total, Muter discovered 1 mutants in 1 files

AnalyticEvent.swift (1 mutants)
⚠️ ⚠️ ⚠️ ⚠️ ⚠️  Muter has encountered an error  ⚠️ ⚠️ ⚠️ ⚠️ ⚠️
Could not parse buildRequest.json from build description path

⚠️ ⚠️ ⚠️ ⚠️ ⚠️  See the Muter error log above this line  ⚠️ ⚠️ ⚠️ ⚠️ ⚠️

If you think this is a bug, or want help figuring out what could be happening, please open an issue at
https://github.com/muter-mutation-testing/muter/issues

Reproduction

Versions

MacOS: Sonoma 14.0 Xcode: 15.0.1 Muter: 16

Nikoloutsos commented 8 months ago

After some investigation I found the culprit behind this. It's the Package.swift. After muter creates a copy of my SPM it messes up with Package.swift More specifically it creates the following:

// swiftformat:disable all
// swiftlint:disable all

import Foundation

// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "Analytics",
    ...

while I think the // swift-tools-version: 5.9 should have been used as first comment as stated in swift docs

Therefore I fixed it by adding the Package.swift in the excluded files 🚀 Should we exclude Package.swift files by default though? Or should we make a special handling there so that the swiftlint comments comes after? Or at least provide a more meaningful error message so that the developer understands what caused the issue?

What do you think?

ZevEisenberg commented 8 months ago

I think it makes sense to exclude Package.swift!

Nikoloutsos commented 8 months ago

@ZevEisenberg I am interested in contributing. So are we okay to make a PR that will exclude it by default?

ZevEisenberg commented 8 months ago

If @rakaramos is ok with it then I am too. Maybe make it a default part of the config file in case the user wants to modify it? But I can't think of a case where we'd want to mutate Package.swift, so just ignoring it internally would probably be ok too.

Nikoloutsos commented 8 months ago

@rakaramos follow up message. Are you okay with that?

rakaramos commented 8 months ago

hi @Nikoloutsos sure thing, go ahead! Thanks for this!

rakaramos commented 4 months ago

@Nikoloutsos closing it as it was already fixed in #258