Skip to content

Commit 83bc5ed

Browse files
Extra. Add support for C# Nunit.
1 parent d37110b commit 83bc5ed

File tree

7 files changed

+64
-9
lines changed

7 files changed

+64
-9
lines changed

extra/Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,17 @@ RUN set -xe && \
9898
apt-get install -y mono-complete mono-vbnc && \
9999
rm -rf /var/lib/apt/lists/*
100100

101-
COPY init-files /init-files
102-
101+
COPY files /files
103102
COPY cron /etc/cron.d
103+
104104
RUN set -xe && \
105105
apt-get update -o Acquire::Check-Valid-Until=false && \
106106
apt-get install -y --no-install-recommends cron && \
107107
rm -rf /var/lib/apt/lists/* && \
108-
cat /etc/cron.d/* | crontab -
108+
cat /etc/cron.d/* | crontab - && \
109+
dotnet restore --packages /NuGet/packages /files/nunit/Test.csproj && \
110+
dotnet nuget locals all --clear && \
111+
rm -rf /files/nunit/obj
109112

110113
COPY docker-entrypoint.sh /
111114
ENTRYPOINT ["/docker-entrypoint.sh"]
File renamed without changes.

extra/files/nunit/Test.csproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<IsPackable>false</IsPackable>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageReference Include="nunit" Version="3.12.0" />
8+
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
9+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0"/>
10+
</ItemGroup>
11+
</Project>

extra/tests/c#-dotnet/lang.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ VERSIONS="3.1.302"
22
NAME="C# (.NET Core SDK $VERSION)"
33
SOURCE_FILE="Main.cs"
44
BINARY_FILE=""
5-
COMPILE_CMD="cp /init-files/Project.csproj . && mkdir -p ~/.dotnet && touch ~/.dotnet/$VERSION.dotnetFirstUseSentinel && /usr/bin/dotnet build $ARGS Project.csproj"
6-
RUN_CMD="/usr/bin/dotnet run --no-build Project.csproj $ARGS"
5+
COMPILE_CMD="cp /files/c#-dotnet/* . && mkdir -p ~/.dotnet && touch ~/.dotnet/$VERSION.dotnetFirstUseSentinel && /usr/bin/dotnet build $ARGS Main.csproj"
6+
RUN_CMD="/usr/bin/dotnet run --no-build Main.csproj $ARGS"

extra/tests/nunit/Test.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using NUnit.Framework;
2+
3+
public class Calculator
4+
{
5+
public int add(int a, int b)
6+
{
7+
return a + b;
8+
}
9+
}
10+
11+
[TestFixture]
12+
public class Tests
13+
{
14+
private Calculator calculator;
15+
16+
[SetUp]
17+
protected void SetUp()
18+
{
19+
calculator = new Calculator();
20+
}
21+
22+
[Test]
23+
public void NeutralElement()
24+
{
25+
Assert.AreEqual(1, calculator.add(1, 0));
26+
Assert.AreEqual(1, calculator.add(0, 1));
27+
Assert.AreEqual(0, calculator.add(0, 0));
28+
}
29+
30+
[Test]
31+
public void CommutativeProperty()
32+
{
33+
Assert.AreEqual(calculator.add(2, 3), calculator.add(3, 2));
34+
}
35+
}

extra/tests/nunit/lang.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
VERSIONS="3.1.302"
2+
NAME="C# Test (.NET Core SDK $VERSION, NUnit 3.12.0)"
3+
SOURCE_FILE="Test.cs"
4+
BINARY_FILE=""
5+
COMPILE_CMD="cp /files/nunit/* . && mkdir -p ~/.dotnet && touch ~/.dotnet/$VERSION.dotnetFirstUseSentinel && dotnet restore --source /NuGet/packages && dotnet build --no-restore $ARGS Test.csproj"
6+
RUN_CMD="/usr/bin/dotnet test --no-build Test.csproj $ARGS"

extra/tests/run

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ for directory in *; do
7979
echo "Compiling inside isolate."
8080

8181
set +e
82-
isolate --cg -i /dev/null -t 15 -x 0 -w 20 -k 128000 -p120 --cg-timing --cg-mem=512000 -f 10240 \
82+
isolate --cg -i /dev/null -t 15 -x 0 -w 20 -k 128000 -p120 --cg-timing --cg-mem=512000 -f 20480 \
8383
-E HOME=/tmp -E PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
84-
-E LANG -E LANGUAGE -E LC_ALL -d /etc:noexec -d /init-files:noexec -d /usr/local/BosqueLanguage/impl:rw --run -- /bin/bash compile
84+
-E LANG -E LANGUAGE -E LC_ALL -d /etc:noexec -d /files:noexec -d /NuGet/packages:noexec -d /usr/local/BosqueLanguage/impl:rw --run -- /bin/bash compile
8585

8686
if [[ $? != 0 ]]; then
8787
if [[ $SKIP_CLEANUP != true ]]; then
@@ -107,9 +107,9 @@ for directory in *; do
107107
echo "Running inside isolate."
108108

109109
set +e
110-
isolate --cg -t 5 -x 0.5 -w 5 -k 64000 -p60 --cg-timing --cg-mem=128000 --share-net -f 5120 \
110+
isolate --cg -t 10 -x 1 -w 15 -k 64000 -p100 --cg-timing --cg-mem=128000 --share-net -f 5120 \
111111
-E HOME=/tmp -E PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
112-
-E LANG -E LANGUAGE -E LC_ALL -d /etc:noexec -d /init-files:noexec --run -- /bin/bash run < $workdir/stdin
112+
-E LANG -E LANGUAGE -E LC_ALL -d /etc:noexec --run -- /bin/bash run < $workdir/stdin
113113

114114
if [[ $? != 0 ]]; then
115115
exit_after_cleanup=true

0 commit comments

Comments
 (0)