diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca867087d..d02b5fa79 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,6 +38,7 @@ jobs: sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin sudo apt-get install \ + binutils-aarch64-linux-gnu \ binutils-mips-linux-gnu \ binutils-powerpc-linux-gnu \ dos2unix \ diff --git a/backend/compilers/download.py b/backend/compilers/download.py index d82899d76..ebd946e4f 100755 --- a/backend/compilers/download.py +++ b/backend/compilers/download.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import argparse import os import platform @@ -539,6 +540,8 @@ def download_wii_gc(): set_x(compiler_dir / "mwcceppc.exe") + (compiler_dir / "license.dat").touch() + shutil.rmtree(COMPILERS_DIR / group_id) # copy in clean 1.2.5 for frank diff --git a/backend/coreapp/diff_wrapper.py b/backend/coreapp/diff_wrapper.py index 18ad2791d..b363a1c7a 100644 --- a/backend/coreapp/diff_wrapper.py +++ b/backend/coreapp/diff_wrapper.py @@ -209,7 +209,7 @@ def diff( if platform == DUMMY: # Todo produce diff for dummy - return {} + return {"rows": ["a", "b"]} try: arch = asm_differ.get_arch(platform.arch or "") diff --git a/backend/coreapp/tests.py b/backend/coreapp/tests.py index 1963869cf..9d90cc7e3 100644 --- a/backend/coreapp/tests.py +++ b/backend/coreapp/tests.py @@ -1,8 +1,9 @@ import tempfile from time import sleep from typing import Any, Callable, Dict, Optional -from unittest import skip, skipIf, skipUnless +from unittest import skip, skipIf from unittest.mock import Mock, patch +from parameterized import parameterized import responses from django.contrib.auth.models import User @@ -15,9 +16,6 @@ from coreapp.compiler_wrapper import CompilerWrapper from coreapp.compilers import ( - GCC272SN, - MWCC_20_72, - MWCC_20_79, Compiler, GCC281, IDO53, @@ -26,14 +24,15 @@ MWCPPC_24, PBX_GCC3, ) +from coreapp.diff_wrapper import DiffWrapper from coreapp.m2c_wrapper import M2CWrapper from coreapp.platforms import N64, NDS_ARM9, PS1 -from coreapp.views.scratch import compile_scratch_update_score +from coreapp.views.scratch import compile_scratch_update_score, diff_compilation from .models.github import GitHubRepo, GitHubUser from .models.profile import Profile from .models.project import Project, ProjectFunction, ProjectImportConfig, ProjectMember -from .models.scratch import CompilerConfig, Scratch +from .models.scratch import Assembly, CompilerConfig, Scratch def requiresCompiler(*compilers: Compiler) -> Callable[..., Any]: @@ -523,27 +522,35 @@ def test_dummy_compiler(self) -> None: len(result.elf_object), 0, "The compilation result should be non-null" ) - def test_all_compilers(self) -> None: - """ - Ensure that we can run a simple compilation for all available compilers - """ - for compiler in compilers.available_compilers(): - # TODO get these working - if compiler in [GCC272SN]: - continue - if compiler.platform in [NDS_ARM9, PS1]: - continue - - result = CompilerWrapper.compile_code( - compiler, - "", - "int func(void) { return 5; }", - "", - "func", - ) - self.assertGreater( - len(result.elf_object), 0, "The compilation result should be non-null" - ) + @parameterized.expand(input=[(c,) for c in compilers.available_compilers()]) # type: ignore + def test_all_compilers(self, compiler: Compiler) -> None: + """ + Ensure that we can run a simple compilation/diff for all available compilers + """ + result = CompilerWrapper.compile_code( + compiler, + "", + "int func(void) { return 5; }", + "", + "func", + ) + self.assertGreater( + len(result.elf_object), + 0, + "The compilation result should be non-null", + ) + + diff = DiffWrapper.diff( + Assembly(elf_object=result.elf_object), + compiler.platform, + "", + result.elf_object, + allow_target_only=True, + diff_flags=[], + ) + + self.assertTrue("rows" in diff) + self.assertGreater(len(diff["rows"]), 0) class DecompilationTests(BaseTestCase): diff --git a/backend/poetry.lock b/backend/poetry.lock index 2c2f2767f..6d6f41f84 100644 --- a/backend/poetry.lock +++ b/backend/poetry.lock @@ -394,6 +394,17 @@ category = "main" optional = false python-versions = "*" +[[package]] +name = "parameterized" +version = "0.8.1" +description = "Parameterized testing with any Python test framework" +category = "dev" +optional = false +python-versions = "*" + +[package.extras] +dev = ["jinja2"] + [[package]] name = "pathspec" version = "0.9.0" @@ -724,7 +735,7 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "5f87333ceabea279ed6886b3d8bda7f4d3526789a83625a31cb49abe70dbb179" +content-hash = "220d633168ddbfd6bb9ea8ddec948934b4bd9a483afb9a2b8ade32fc784ce0e4" [metadata.files] ansiwrap = [ @@ -981,6 +992,7 @@ mypy-extensions = [ {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, ] +parameterized = [] pathspec = [ {file = "pathspec-0.9.0-py2.py3-none-any.whl", hash = "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a"}, {file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"}, diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 6a1dba33c..e1fe3f037 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -34,6 +34,7 @@ django-stubs-ext = "^0.4.0" django-stubs = "1.9.0" djangorestframework-stubs = "^1.4.0" types-requests = "^2.27.15" +parameterized = "^0.8.1" [build-system] requires = ["poetry-core>=1.0.0"]