Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
*
!bin/run.sh
!bin/run-tests.sh
!src/Exercism.TestRunner.FSharp
src/Exercism.TestRunner.FSharp/bin
src/Exercism.TestRunner.FSharp/obj
.appends
.git
.github
.gitignore
.gitattributes
.dockerignore
Dockerfile
!/bin/run.sh
!/src/Exercism.TestRunner.FSharp
/src/Exercism.TestRunner.FSharp/bin
/src/Exercism.TestRunner.FSharp/obj
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
build:
name: Tests
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
Expand Down
49 changes: 26 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS build
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0.103-alpine3.23 AS build
ARG TARGETARCH

WORKDIR /tmp

# Pre-install packages for offline usage
RUN dotnet new console
RUN dotnet add package Microsoft.NET.Test.Sdk -v 16.8.3
RUN dotnet add package xunit -v 2.4.1
RUN dotnet add package xunit.runner.visualstudio -v 2.4.3
RUN dotnet add package FsUnit -v 4.0.4
RUN dotnet add package FsUnit.xUnit -v 4.0.4
RUN dotnet add package Exercism.Tests -v 0.1.0-alpha
RUN dotnet add package Exercism.Tests -v 0.1.0-beta1
RUN dotnet add package Aether -v 8.3.1
RUN dotnet add package BenchmarkDotNet -v 0.12.1
RUN dotnet add package FakeItEasy -v 6.2.1
RUN dotnet add package FsCheck -v 2.14.3
RUN dotnet add package FsCheck -v 2.16.3
RUN dotnet add package FsCheck.Xunit -v 2.14.3
RUN dotnet add package FSharp.Core -v 6.0.1
RUN dotnet add package FSharp.Core -v 7.0.400
RUN dotnet add package FSharp.Core -v 8.0.101
RUN dotnet add package FSharp.Core -v 8.0.403
RUN dotnet add package FSharp.Core -v 9.0.201
RUN dotnet add package FParsec -v 1.1.1
RUN dotnet add package FsToolkit.ErrorHandling -v 4.15.2
RUN dotnet add package Microsoft.NET.Test.Sdk --version 16.8.3
RUN dotnet add package Microsoft.NET.Test.Sdk --version 18.3.0
RUN dotnet add package xunit --version 2.4.1
RUN dotnet add package xunit.v3 --version 3.2.2
RUN dotnet add package xunit.runner.visualstudio --version 2.4.3
RUN dotnet add package xunit.runner.visualstudio --version 3.1.5
RUN dotnet add package FsUnit --version 4.0.4
RUN dotnet add package FsUnit.xUnit --version 4.0.4
RUN dotnet add package FsUnit.xUnit --version 7.1.1
RUN dotnet add package Exercism.Tests --version 0.1.0-alpha
RUN dotnet add package Exercism.Tests --version 0.1.0-beta1
RUN dotnet add package Exercism.Tests.xunit.v3 --version 0.1.0-beta1
RUN dotnet add package Aether --version 8.3.1
RUN dotnet add package BenchmarkDotNet --version 0.12.1
RUN dotnet add package FakeItEasy --version 6.2.1
RUN dotnet add package FsCheck --version 2.14.3
RUN dotnet add package FsCheck --version 3.3.2
RUN dotnet add package FsCheck.Xunit --version 2.14.3
RUN dotnet add package FsCheck.Xunit.v3 --version 3.3.2
RUN dotnet add package FSharp.Core --version 9.0.201
RUN dotnet add package FSharp.Core --version 10.0.103
RUN dotnet add package FParsec --version 1.1.1
RUN dotnet add package FsToolkit.ErrorHandling --version 4.15.2

WORKDIR /app

Expand All @@ -37,7 +40,7 @@ COPY src/Exercism.TestRunner.FSharp/ ./
RUN dotnet publish -a $TARGETARCH -c Release -o /opt/test-runner --no-restore

# Build runtime image
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS runtime
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0.103-alpine3.23 AS runtime

ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
ENV DOTNET_ROLL_FORWARD=Major
Expand All @@ -48,6 +51,6 @@ WORKDIR /opt/test-runner

COPY --from=build /root/.nuget/packages/ /root/.nuget/packages/
COPY --from=build /opt/test-runner/ .
COPY bin/ bin/
COPY bin/run.sh bin/run.sh

ENTRYPOINT ["sh", "/opt/test-runner/bin/run.sh"]
16 changes: 0 additions & 16 deletions Exercism.TestRunner.FSharp.sln

This file was deleted.

3 changes: 3 additions & 0 deletions Exercism.TestRunner.FSharp.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="src/Exercism.TestRunner.FSharp/Exercism.TestRunner.FSharp.fsproj" />
</Solution>
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This repository contains the F# test runner, which implements the [test runner i
To run a solution's tests, follow these steps:

1. Open a command prompt in the root directory.
1. Run `./run.ps1 <exercise> <input-directory> <output-directory>`. This script will:
1. Run `./bin/run.sh <exercise> <input-directory> <output-directory>`. This script will:
1. Make sure all tests run (no skipped tests) for the solution found in `<input-directory>`.
1. Run all the tests.
1. Once the script has completed, the test results will be written to `<output-directory>/results.json`.
Expand All @@ -19,7 +19,7 @@ To run a solution's tests, follow these steps:
To run a solution's tests using a Docker container, follow these steps:

1. Open a command prompt in the root directory.
1. Run `./run-in-docker.ps1 <exercise> <input-directory> <output-directory>`. This script will:
1. Run `./bin/run-in-docker.sh <exercise> <input-directory> <output-directory>`. This script will:
1. Make sure all tests run (no skipped tests) for the solution found in `<input-directory>`.
1. Run all the tests.
1. Once the script has completed, the test results will be written to `<output-directory>/results.json`.
Expand Down
1 change: 0 additions & 1 deletion bin/run-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ docker build --rm -t exercism/fsharp-test-runner .
docker run \
--rm \
--network none \
--read-only \
--mount type=bind,src="${solution_dir}",dst=/solution \
--mount type=bind,src="${output_dir}",dst=/output \
--mount type=tmpfs,dst=/tmp \
Expand Down
2 changes: 1 addition & 1 deletion bin/run-tests-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ docker build --rm -t exercism/fsharp-test-runner .
docker run \
--rm \
--network none \
--read-only \
--mount type=bind,src="${PWD}/tests",dst=/opt/test-runner/tests \
--mount type=bind,src="${PWD}/bin/run-tests.sh",dst=/opt/test-runner/bin/run-tests.sh \
--mount type=tmpfs,dst=/tmp \
--workdir /opt/test-runner \
--entrypoint /opt/test-runner/bin/run-tests.sh \
Expand Down
13 changes: 13 additions & 0 deletions bin/update-golden-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env sh

# Synopsis:
# Update the golden tests.

# Example:
# ./bin/update-golden-tests.sh

# Generate the up-to-date results.json
./bin/run-tests-in-docker.sh

# Overwrite the existing files
find tests -name results.json -execdir cp results.json expected_results.json \;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand All @@ -20,10 +20,10 @@

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Fantomas.Core" Version="6.3.4" />
<PackageReference Include="Fantomas.FCS" Version="6.3.4" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Update="FSharp.Core" Version="9.0.201" />
<PackageReference Include="Fantomas.Core" Version="7.0.5" />
<PackageReference Include="Fantomas.FCS" Version="7.0.5" />
<PackageReference Include="Humanizer.Core" Version="3.0.1" />
<PackageReference Update="FSharp.Core" Version="10.0.103" />
</ItemGroup>

</Project>
12 changes: 6 additions & 6 deletions src/Exercism.TestRunner.FSharp/Rewrite.fs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ let private enableAllTests parsedInput =
let private rewriteProjectFile (context: TestRunContext) =
let originalProjectFile = File.ReadAllText(context.ProjectFile)
let rewrittenProjectFile =
originalProjectFile
.Replace("net5.0", "net9.0")
.Replace("net6.0", "net9.0")
.Replace("net7.0", "net9.0")
.Replace("net8.0", "net9.0")
originalProjectFile, rewrittenProjectFile
if originalProjectFile.Contains("<RootNamespace>") then
originalProjectFile.Replace("net9.0", "net10.0")
else
originalProjectFile.Replace("net9.0", "net10.0")
.Replace("</PropertyGroup>", "<RootNamespace>Exercism</RootNamespace>\n </PropertyGroup>")
originalProjectFile, rewrittenProjectFile

let rewriteTests (context: TestRunContext) =
match parseFile context.TestsFile with
Expand Down
4 changes: 2 additions & 2 deletions src/Exercism.TestRunner.FSharp/Testing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ module DotnetCli =
else
error.[lastPathIndex + 1..]

let private removeProjectReference (error: string) = error.[0..(error.LastIndexOf('[') - 1)]
let private removeProjectReference (error: string) = error[.. error.LastIndexOf('[') - 1]

let private normalizeBuildError error =
error
Expand All @@ -258,7 +258,7 @@ module DotnetCli =
let solutionDir = Path.GetDirectoryName(context.TestsFile)

Process.exec "dotnet" "restore --source /root/.nuget/packages/" solutionDir
Process.exec "dotnet" $"test --no-restore --verbosity=quiet --logger \"trx;LogFileName=%s{Path.GetFileName(context.TestResultsFile)}\" /flp:verbosity=quiet;errorsOnly=true" solutionDir
Process.exec "dotnet" $"test -c release --no-restore --verbosity=quiet --logger \"trx;LogFileName={Path.GetFileName(context.TestResultsFile)}\" /flp:verbosity=quiet;errorsOnly=true" solutionDir

let buildErrors = parseBuildErrors context

Expand Down
10 changes: 8 additions & 2 deletions src/Exercism.TestRunner.FSharp/Visitor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ type SyntaxVisitor() =
| SynMemberDefn.AutoProperty(attrs, isStatic, ident, typeOpt, propKind, flags, flagsForSet, doc, access, synExpr, range, trivia) ->
SynMemberDefn.AutoProperty
(attrs |> List.map this.VisitSynAttributeList, isStatic, this.VisitIdent ident,
Option.map this.VisitSynType typeOpt, propKind, flags, flagsForSet, this.VisitPreXmlDoc(doc), Option.map this.VisitSynAccess access,
Option.map this.VisitSynType typeOpt, propKind, flags, flagsForSet, this.VisitPreXmlDoc(doc), this.VisitSynValSigAccess access,
this.VisitSynExpr synExpr, range, trivia)

abstract VisitSynSimplePat: SynSimplePat -> SynSimplePat
Expand Down Expand Up @@ -395,7 +395,7 @@ type SyntaxVisitor() =
SynValSig
(attrs |> List.map this.VisitSynAttributeList, this.VisitSynIdent ident,
this.VisitSynValTyparDecls explicitValDecls, this.VisitSynType synType, this.VisitSynValInfo arity,
isInline, isMutable, this.VisitPreXmlDoc(doc), Option.map this.VisitSynAccess access, Option.map this.VisitSynExpr expr,
isInline, isMutable, this.VisitPreXmlDoc(doc), this.VisitSynValSigAccess access, Option.map this.VisitSynExpr expr,
range, trivia)

abstract VisitSynValTyparDecls: SynValTyparDecls -> SynValTyparDecls
Expand Down Expand Up @@ -632,6 +632,8 @@ type SyntaxVisitor() =
SynType.SignatureParameter(List.map this.VisitSynAttributeList synAttributeLists, optional, Option.map this.VisitIdent identOption, this.VisitSynType usedType, range)
| SynType.FromParseError range -> SynType.FromParseError range
| SynType.Intersection(typar, types, range, trivia) -> SynType.Intersection(Option.map this.VisitSynTypar typar, types |> List.map this.VisitSynType, range, trivia)
| SynType.StaticConstantNull range -> SynType.StaticConstantNull range
| SynType.WithNull(innerType, ambivalent, range, trivia) -> SynType.WithNull(this.VisitSynType(innerType), ambivalent, range, trivia)

abstract VisitSynTypeOrTrivia: SynTypeOrTrivia -> SynTypeOrTrivia
default this.VisitSynTypeOrTrivia(synTypeOrTrivia: SynTypeOrTrivia): SynTypeOrTrivia = synTypeOrTrivia
Expand Down Expand Up @@ -664,6 +666,10 @@ type SyntaxVisitor() =
abstract VisitSynAccess: SynAccess -> SynAccess

default this.VisitSynAccess(a: SynAccess): SynAccess = a

abstract VisitSynValSigAccess: SynValSigAccess -> SynValSigAccess

default this.VisitSynValSigAccess(a: SynValSigAccess): SynValSigAccess = a

abstract VisitSynBindingKind: SynBindingKind -> SynBindingKind

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ClassBasedTests
module AllTestsFailing

let add x y = x + y

Expand Down
22 changes: 22 additions & 0 deletions tests/AllTestsFailing/AllTestsFailing.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>Exercism</RootNamespace>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<Compile Include="AllTestsFailing.fs" />
<Compile Include="AllTestsFailingTests.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageReference Include="FsUnit.xUnit" Version="7.1.1" />
<PackageReference Include="Exercism.Tests.xunit.v3" Version="0.1.0-beta1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module MultipleTestsWithMultipleFailsTests
module AllTestsFailingTests

open Xunit
open FsUnit.Xunit
open Exercism.Tests
open MultipleTestsWithMultipleFails
open AllTestsFailing

[<Fact>]
let ``Add should add numbers`` () = add 1 1 |> should equal 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Add should add numbers",
"status": "fail",
"message": "Expected: Equals 3\nActual: 2",
"message": "Assert.Equal() Failure: Values differ\nExpected: \u0022Equals 3\u0022\nActual: \u00222\u0022",
"test_code": "add 1 1 |\u003E should equal 3"
},
{
Expand All @@ -16,7 +16,7 @@
{
"name": "Mul should multiply numbers",
"status": "fail",
"message": "Expected: Equals 7\nActual: 6",
"message": "Assert.Equal() Failure: Values differ\nExpected: \u0022Equals 7\u0022\nActual: \u00226\u0022",
"test_code": "mul 2 3 |\u003E should equal 7"
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module AllTestsWithTask
module AllTestsPassing

let add x y = x + y

Expand Down
22 changes: 22 additions & 0 deletions tests/AllTestsPassing/AllTestsPassing.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>Exercism</RootNamespace>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<Compile Include="AllTestsPassing.fs" />
<Compile Include="AllTestsPassingTests.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageReference Include="FsUnit.xUnit" Version="7.1.1" />
<PackageReference Include="Exercism.Tests.xunit.v3" Version="0.1.0-beta1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module DotnetSixProjectTests
module AllTestsPassingTests

open Xunit
open FsUnit.Xunit
open Exercism.Tests
open DotnetSixProject
open AllTestsPassing

[<Fact>]
let ``Add should add numbers`` () = add 1 1 |> should equal 2
Expand Down
22 changes: 0 additions & 22 deletions tests/AllTestsWithTask/AllTestsWithTask.fsproj

This file was deleted.

Loading
Loading