From d69a4278bacf3f744883bf07c5db69c3ae30c014 Mon Sep 17 00:00:00 2001 From: Tim Bussmann Date: Fri, 14 Oct 2022 22:52:13 +0200 Subject: [PATCH 01/10] dotnet 6 executor first attempt --- dmoj/executors/NETCS.py | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 dmoj/executors/NETCS.py diff --git a/dmoj/executors/NETCS.py b/dmoj/executors/NETCS.py new file mode 100644 index 000000000..1ced6d89d --- /dev/null +++ b/dmoj/executors/NETCS.py @@ -0,0 +1,48 @@ +import os + +from dmoj.cptbox.filesystem_policies import ExactFile, RecursiveDir +from dmoj.executors.compiled_executor import CompiledExecutor + +CSPROJ = b"""\ + + + Exe + net6.0 + enable + enable + true + + +""" + +HELLO_WORLD_PROGRAM = """\ +Console.WriteLine("Hello, World!"); +""" + +class Executor(CompiledExecutor): + ext = 'cs' + command = 'dotnet' + test_program = HELLO_WORLD_PROGRAM + compiler_time_limit = 20 + compiler_write_fs = [ + RecursiveDir('~/.nuget/packages'), + RecursiveDir('~/.local/share/NuGet'), + RecursiveDir('/tmp/NuGetScratch'), + ] + + def create_files(self, problem_id, source_code, *args, **kwargs): + with open(self._file('Program.cs'), 'wb') as f: + f.write(source_code) + + with open(self._file('DMOJ.csproj'), 'wb') as f: + f.write(CSPROJ) + + @classmethod + def get_versionable_commands(cls): + return [('dotnet', os.path.join(os.path.dirname(cls.get_command()), 'dotnet'))] + + def get_compile_args(self): + return [self.get_command(), 'publish', '--configuration', 'release', '--self-contained', 'false'] + + def get_compiled_file(self): + return self._file('bin', 'release', 'net6.0', 'DMOJ.exe') From dc51b6c138b395bf5b207dea8abbe2e94a61e703 Mon Sep 17 00:00:00 2001 From: Tim Bussmann Date: Fri, 14 Oct 2022 23:14:35 +0200 Subject: [PATCH 02/10] remove get_versionable_commands --- dmoj/executors/NETCS.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/dmoj/executors/NETCS.py b/dmoj/executors/NETCS.py index 1ced6d89d..f2c2f079e 100644 --- a/dmoj/executors/NETCS.py +++ b/dmoj/executors/NETCS.py @@ -19,6 +19,7 @@ Console.WriteLine("Hello, World!"); """ + class Executor(CompiledExecutor): ext = 'cs' command = 'dotnet' @@ -37,12 +38,8 @@ def create_files(self, problem_id, source_code, *args, **kwargs): with open(self._file('DMOJ.csproj'), 'wb') as f: f.write(CSPROJ) - @classmethod - def get_versionable_commands(cls): - return [('dotnet', os.path.join(os.path.dirname(cls.get_command()), 'dotnet'))] - def get_compile_args(self): return [self.get_command(), 'publish', '--configuration', 'release', '--self-contained', 'false'] def get_compiled_file(self): - return self._file('bin', 'release', 'net6.0', 'DMOJ.exe') + return self._file('bin', 'release', 'net6.0', 'DMOJ.exe') \ No newline at end of file From 3857f0e8d7149d316e958b9bc07a2f5ef9d0374c Mon Sep 17 00:00:00 2001 From: Tim Bussmann Date: Tue, 18 Oct 2022 22:24:53 +0200 Subject: [PATCH 03/10] add newline at end of file --- dmoj/executors/NETCS.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmoj/executors/NETCS.py b/dmoj/executors/NETCS.py index f2c2f079e..801f0a731 100644 --- a/dmoj/executors/NETCS.py +++ b/dmoj/executors/NETCS.py @@ -42,4 +42,4 @@ def get_compile_args(self): return [self.get_command(), 'publish', '--configuration', 'release', '--self-contained', 'false'] def get_compiled_file(self): - return self._file('bin', 'release', 'net6.0', 'DMOJ.exe') \ No newline at end of file + return self._file('bin', 'release', 'net6.0', 'DMOJ.exe') From 7d950bdfb6973f83b98fd75e78bf25c333cf418a Mon Sep 17 00:00:00 2001 From: Tim Bussmann Date: Tue, 18 Oct 2022 22:57:04 +0200 Subject: [PATCH 04/10] implement hello world behavior --- dmoj/executors/NETCS.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dmoj/executors/NETCS.py b/dmoj/executors/NETCS.py index 801f0a731..5563b5580 100644 --- a/dmoj/executors/NETCS.py +++ b/dmoj/executors/NETCS.py @@ -3,7 +3,7 @@ from dmoj.cptbox.filesystem_policies import ExactFile, RecursiveDir from dmoj.executors.compiled_executor import CompiledExecutor -CSPROJ = b"""\ +CSPROJ = """ Exe @@ -15,15 +15,16 @@ """ -HELLO_WORLD_PROGRAM = """\ -Console.WriteLine("Hello, World!"); -""" - - class Executor(CompiledExecutor): ext = 'cs' command = 'dotnet' - test_program = HELLO_WORLD_PROGRAM + test_program = """ +string? line; +while (!string.IsNullOrEmpty(line = Console.ReadLine())) +{ + Console.WriteLine(line); +} + """ compiler_time_limit = 20 compiler_write_fs = [ RecursiveDir('~/.nuget/packages'), From e9489821896503c51635090a1f2f4758906a266b Mon Sep 17 00:00:00 2001 From: Tim Bussmann Date: Tue, 18 Oct 2022 23:12:07 +0200 Subject: [PATCH 05/10] remove PublishSingleFile due to lack of reliable runtime identifier --- dmoj/executors/NETCS.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dmoj/executors/NETCS.py b/dmoj/executors/NETCS.py index 5563b5580..1c1578cc8 100644 --- a/dmoj/executors/NETCS.py +++ b/dmoj/executors/NETCS.py @@ -3,14 +3,13 @@ from dmoj.cptbox.filesystem_policies import ExactFile, RecursiveDir from dmoj.executors.compiled_executor import CompiledExecutor -CSPROJ = """ +CSPROJ = """\ Exe net6.0 enable enable - true """ From 94ba0f92321780f2733be7358518cc3c4b606ef0 Mon Sep 17 00:00:00 2001 From: Tim Bussmann Date: Tue, 18 Oct 2022 23:12:18 +0200 Subject: [PATCH 06/10] cleanup imports --- dmoj/executors/NETCS.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dmoj/executors/NETCS.py b/dmoj/executors/NETCS.py index 1c1578cc8..829937c40 100644 --- a/dmoj/executors/NETCS.py +++ b/dmoj/executors/NETCS.py @@ -1,6 +1,4 @@ -import os - -from dmoj.cptbox.filesystem_policies import ExactFile, RecursiveDir +from dmoj.cptbox.filesystem_policies import RecursiveDir from dmoj.executors.compiled_executor import CompiledExecutor CSPROJ = """\ From 414ed203d6ee1229aaae85bd4c02040095a8befe Mon Sep 17 00:00:00 2001 From: Tim Bussmann Date: Tue, 18 Oct 2022 23:12:46 +0200 Subject: [PATCH 07/10] fix executable path --- dmoj/executors/NETCS.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmoj/executors/NETCS.py b/dmoj/executors/NETCS.py index 829937c40..33ca81a61 100644 --- a/dmoj/executors/NETCS.py +++ b/dmoj/executors/NETCS.py @@ -40,4 +40,4 @@ def get_compile_args(self): return [self.get_command(), 'publish', '--configuration', 'release', '--self-contained', 'false'] def get_compiled_file(self): - return self._file('bin', 'release', 'net6.0', 'DMOJ.exe') + return self._file('bin', 'release', 'net6.0', 'publish', 'DMOJ') From a462bb98e6b2387077cc501d89a1a7aa164e756c Mon Sep 17 00:00:00 2001 From: Tim Bussmann Date: Tue, 18 Oct 2022 23:13:03 +0200 Subject: [PATCH 08/10] minor tweak --- dmoj/executors/NETCS.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dmoj/executors/NETCS.py b/dmoj/executors/NETCS.py index 33ca81a61..be3a96f52 100644 --- a/dmoj/executors/NETCS.py +++ b/dmoj/executors/NETCS.py @@ -15,13 +15,12 @@ class Executor(CompiledExecutor): ext = 'cs' command = 'dotnet' - test_program = """ + test_program = """\ string? line; while (!string.IsNullOrEmpty(line = Console.ReadLine())) { Console.WriteLine(line); -} - """ +}""" compiler_time_limit = 20 compiler_write_fs = [ RecursiveDir('~/.nuget/packages'), From 94b5f8f2489878b417f0f1539d83ff872ad30868 Mon Sep 17 00:00:00 2001 From: Tim Bussmann Date: Wed, 19 Oct 2022 11:17:42 +0200 Subject: [PATCH 09/10] fix linter complaints --- dmoj/executors/NETCS.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dmoj/executors/NETCS.py b/dmoj/executors/NETCS.py index be3a96f52..6f4e24452 100644 --- a/dmoj/executors/NETCS.py +++ b/dmoj/executors/NETCS.py @@ -12,6 +12,7 @@ """ + class Executor(CompiledExecutor): ext = 'cs' command = 'dotnet' @@ -19,7 +20,7 @@ class Executor(CompiledExecutor): string? line; while (!string.IsNullOrEmpty(line = Console.ReadLine())) { - Console.WriteLine(line); + Console.WriteLine(line); }""" compiler_time_limit = 20 compiler_write_fs = [ From 4c740a77954d9924858ca87ab9057fceebfae14a Mon Sep 17 00:00:00 2001 From: Tim Bussmann Date: Wed, 19 Oct 2022 23:19:16 +0200 Subject: [PATCH 10/10] fix csproj const --- dmoj/executors/NETCS.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmoj/executors/NETCS.py b/dmoj/executors/NETCS.py index 6f4e24452..69b78918c 100644 --- a/dmoj/executors/NETCS.py +++ b/dmoj/executors/NETCS.py @@ -1,7 +1,7 @@ from dmoj.cptbox.filesystem_policies import RecursiveDir from dmoj.executors.compiled_executor import CompiledExecutor -CSPROJ = """\ +CSPROJ = b"""\ Exe