From 024fec32906b48b73654f31fc79804455607a4f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Wed, 6 Dec 2023 11:23:15 -0300 Subject: [PATCH] Fix shuffling tests not being generated --- lib/mix/tasks/generate_spec_tests.ex | 15 +++++++++++---- lib/spec/runners/shuffling.ex | 9 +++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/mix/tasks/generate_spec_tests.ex b/lib/mix/tasks/generate_spec_tests.ex index 17d3d39cf..56a89210c 100644 --- a/lib/mix/tasks/generate_spec_tests.ex +++ b/lib/mix/tasks/generate_spec_tests.ex @@ -10,23 +10,30 @@ defmodule Mix.Tasks.GenerateSpecTests do use Mix.Task require Logger - @configs ["mainnet", "minimal"] - @forks ["altair", "deneb", "phase0"] + @configs ["mainnet", "minimal", "general"] + @forks ["phase0", "altair", "bellatrix", "capella", "deneb"] @shortdoc "Generates tests for spec test files" @impl Mix.Task def run(_args) do {:ok, file_names} = File.ls(Path.join(["lib", "spec", "runners"])) - runners = Enum.map(file_names, fn file_name -> Path.basename(file_name, ".ex") end) + runners = Enum.map(file_names, &Path.basename(&1, ".ex")) + # Generate all tests for Capella fork for config <- @configs, runner <- runners do generate_test(config, "capella", runner) end + # Generate tests for all forks in general preset for fork <- @forks, runner <- runners do generate_test("general", fork, runner) end + # Generate shuffling tests for all testcases + for config <- @configs, fork <- @forks do + generate_test(config, fork, "shuffling") + end + File.touch(Path.join(["test", "generated"])) end @@ -45,9 +52,9 @@ defmodule Mix.Tasks.GenerateSpecTests do end defp test_module(cases, config, fork, runner) do - r = Macro.camelize(runner) c = Macro.camelize(config) f = Macro.camelize(fork) + r = Macro.camelize(runner) module_name = "Elixir.#{c}.#{f}.#{r}Test" |> String.to_atom() runner_module = "Elixir.#{r}TestRunner" |> String.to_atom() diff --git a/lib/spec/runners/shuffling.ex b/lib/spec/runners/shuffling.ex index f6cec793e..740c7e714 100644 --- a/lib/spec/runners/shuffling.ex +++ b/lib/spec/runners/shuffling.ex @@ -1,12 +1,13 @@ defmodule ShufflingTestRunner do - alias LambdaEthereumConsensus.StateTransition.Misc - use ExUnit.CaseTemplate - use TestRunner - @moduledoc """ Runner for Operations test cases. See: https://github.com/ethereum/consensus-specs/tree/dev/tests/formats/shuffling """ + use ExUnit.CaseTemplate + use TestRunner + + alias LambdaEthereumConsensus.StateTransition.Misc + # Remove handler from here once you implement the corresponding functions @disabled_handlers [ # "core"