diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 33afe2c..0000000 --- a/.gitignore +++ /dev/null @@ -1,213 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# Build results -[Bb]in/ -[Oo]bj/ -[Ee]xt/ -[Ll]og/ -[Ll]ogs/ - -# MSBuild Binary and Structured Log -*.binlog - -# MSBuild response files -!MSBuild.rsp -!Directory.Build.rsp - -# Visual Studio 14+ cache/options directory -.vs/ - -# Visual Studio 15+ auto generated files -Generated\ Files/ - -# Local History for Visual Studio -.localhistory/ - -# Visual Studio History (VSHistory) files -.vshistory/ - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# VS Code files for those working on multiple tools -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -# Local History for Visual Studio Code -.history/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUnit -*.VisualState.xml -TestResult.xml -nunit-*.xml - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.tlog -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# NuGet Symbol Packages -*.snupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx -*.appxbundle -*.appxupload - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*~.* -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# Microsoft Fakes -FakesAssemblies/ - -# CodeRush personal settings -.cr/personal - -# JetBrains Rider -*.sln.iml - -# Codex -.codex diff --git a/MutationCase.fs b/MutationCase.fs index 12e6475..33891ef 100644 --- a/MutationCase.fs +++ b/MutationCase.fs @@ -1,4 +1,4 @@ -namespace Mutannot +namespace Mutation open System diff --git a/example-tests/Example.Tests/Calculator.fs b/example-tests/Example.Tests/Calculator.fs deleted file mode 100644 index cfcce3b..0000000 --- a/example-tests/Example.Tests/Calculator.fs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Example - -module Calculator = - let addOne value = value + 1 - - let absoluteDifference left right = - if left >= right then left - right else right - left - - let isLeapYear year = - year % 4 = 0 && (year % 100 <> 0 || year % 400 = 0) diff --git a/example-tests/Example.Tests/CalculatorTests.fs b/example-tests/Example.Tests/CalculatorTests.fs deleted file mode 100644 index f05ee54..0000000 --- a/example-tests/Example.Tests/CalculatorTests.fs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Example.Tests - -open Example -open Mutannot -open Xunit - -type CalculatorTests() = - [] - [] - member _.AddOne_increments() = - Assert.Equal(42, Calculator.addOne 41) - - [] - [] - member _.AbsoluteDifference_preserves_order() = - Assert.Equal(7, Calculator.absoluteDifference 10 3) - - [] - [ 0", "year % 100 = 0")>] - member _.LeapYear_handles_centuries() = - Assert.True(Calculator.isLeapYear 2000) - Assert.False(Calculator.isLeapYear 1900) diff --git a/example-tests/Example.Tests/Example.Tests.fsproj b/example-tests/Example.Tests/Example.Tests.fsproj deleted file mode 100644 index c8c7dce..0000000 --- a/example-tests/Example.Tests/Example.Tests.fsproj +++ /dev/null @@ -1,21 +0,0 @@ - - - net10.0 - false - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - diff --git a/example-tests/Example.Tests/MutationCaseAttribute.fs b/example-tests/Example.Tests/MutationCaseAttribute.fs deleted file mode 100644 index 12e6475..0000000 --- a/example-tests/Example.Tests/MutationCaseAttribute.fs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Mutannot - -open System - -[] -type MutationCaseAttribute(id: string, file: string, line: int, find: string, replace: string) = - inherit Attribute() - - member _.Id = id - member _.File = file - member _.Line = line - member _.Find = find - member _.Replace = replace diff --git a/verify-coverage-mutants.fsx b/verify-coverage-mutants.fsx index ed5f988..25c43b4 100644 --- a/verify-coverage-mutants.fsx +++ b/verify-coverage-mutants.fsx @@ -12,11 +12,6 @@ type MutationCase = TestName: string DeclaringType: string } -type MutationOutcome = - | Killed - | Survived - | BuildFailed - type Command = | List | Show of string @@ -120,7 +115,7 @@ let mutationCases () = t.GetMethods(BindingFlags.Public ||| BindingFlags.NonPublic ||| BindingFlags.Static ||| BindingFlags.Instance) |> Array.collect (fun m -> m.GetCustomAttributesData() - |> Seq.filter (fun attr -> attr.AttributeType.FullName = "Mutannot.MutationCaseAttribute") + |> Seq.filter (fun attr -> attr.AttributeType.FullName = "FsCheck.Test.MutationCaseAttribute") |> Seq.map (fun attr -> let args = attr.ConstructorArguments if args.Count <> 5 then failwithf "Unexpected MutationCaseAttribute shape on %s.%s" t.FullName m.Name @@ -208,26 +203,15 @@ let runMutation (mutation: MutationCase) = File.WriteAllText(targetFile, mutatedText) printfn "==> %s: %s" mutation.Id mutation.TestName - let buildExitCode = - runProcess worktreePath "dotnet" [ "build"; testProjectPath; "--configuration"; options.Configuration; "--nologo" ] - - let outcome = - if buildExitCode <> 0 then - printfn "BUILD FAILED %s" mutation.Id - BuildFailed - else - let testExitCode = - runProcess worktreePath "dotnet" [ "test"; testProjectPath; "--configuration"; options.Configuration; "--filter"; testFilter mutation; "--no-build"; "--nologo" ] - - if testExitCode = 0 then - printfn "SURVIVED %s" mutation.Id - Survived - else - printfn "KILLED %s" mutation.Id - Killed - + let exitCode = runProcess worktreePath "dotnet" [ "test"; testProjectPath; "--configuration"; options.Configuration; "--filter"; testFilter mutation; "--nologo" ] File.WriteAllText(targetFile, originalText) - outcome + + if exitCode = 0 then + printfn "SURVIVED %s" mutation.Id + false + else + printfn "KILLED %s" mutation.Id + true let mutations = mutationCases () @@ -250,14 +234,13 @@ match options.Command with try createWorktree () - let outcomes = + let killed = requested |> List.map runMutation - let survivors = outcomes |> List.filter ((=) Survived) |> List.length - let buildFailures = outcomes |> List.filter ((=) BuildFailed) |> List.length - if survivors = 0 && buildFailures = 0 then + let survivors = killed |> List.filter not |> List.length + if survivors = 0 then printfn "All requested mutants were killed." else - fail $"{survivors} mutant(s) survived. {buildFailures} mutant(s) failed to build." + fail $"{survivors} mutant(s) survived." finally cleanup ()