mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-09 01:04:14 +00:00
run yaml test generators from makefile
This commit is contained in:
parent
f2703bc8d3
commit
adf91f50c5
27
Makefile
27
Makefile
@ -5,12 +5,12 @@ PY_SPEC_DIR = $(TEST_LIBS_DIR)/pyspec
|
|||||||
PY_TEST_DIR = ./py_tests
|
PY_TEST_DIR = ./py_tests
|
||||||
YAML_TEST_DIR = ./yaml_tests
|
YAML_TEST_DIR = ./yaml_tests
|
||||||
GENERATOR_DIR = ./test_generators
|
GENERATOR_DIR = ./test_generators
|
||||||
GENERATOR_VENVS_DIR = $(GENERATOR_DIR)/.venvs
|
|
||||||
|
|
||||||
# Collect a list of generator names
|
# Collect a list of generator names
|
||||||
GENERATORS = $(sort $(dir $(wildcard $(GENERATOR_DIR)/*/)))
|
GENERATORS = $(sort $(dir $(wildcard $(GENERATOR_DIR)/*/)))
|
||||||
# Map this list of generator paths to a list of test output paths
|
# Map this list of generator paths to a list of test output paths
|
||||||
YAML_TEST_TARGETS = $(patsubst $(GENERATOR_DIR)/%, $(YAML_TEST_DIR)/%, $(GENERATORS))
|
YAML_TEST_TARGETS = $(patsubst $(GENERATOR_DIR)/%, $(YAML_TEST_DIR)/%, $(GENERATORS))
|
||||||
|
GENERATOR_VENVS = $(patsubst $(GENERATOR_DIR)/%, $(GENERATOR_DIR)/%/venv, $(GENERATORS))
|
||||||
|
|
||||||
PY_SPEC_PHASE_0_TARGETS = $(PY_SPEC_DIR)/eth2/phase0/spec.py
|
PY_SPEC_PHASE_0_TARGETS = $(PY_SPEC_DIR)/eth2/phase0/spec.py
|
||||||
PY_SPEC_ALL_TARGETS = $(PY_SPEC_PHASE_0_TARGETS)
|
PY_SPEC_ALL_TARGETS = $(PY_SPEC_PHASE_0_TARGETS)
|
||||||
@ -22,11 +22,12 @@ all: $(YAML_TEST_DIR) $(YAML_TEST_TARGETS) $(PY_SPEC_ALL_TARGETS)
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(YAML_TEST_DIR)
|
rm -rf $(YAML_TEST_DIR)
|
||||||
rm -rf $(GENERATOR_VENVS_DIR)
|
rm -rf $(GENERATOR_VENVS)
|
||||||
|
rm -rf $(PY_TEST_DIR)/venv
|
||||||
rm -rf $(PY_SPEC_ALL_TARGETS)
|
rm -rf $(PY_SPEC_ALL_TARGETS)
|
||||||
|
|
||||||
# "make yaml_tests" to run generators
|
# "make gen_yaml_tests" to run generators
|
||||||
yaml_tests: $(YAML_TEST_TARGETS)
|
gen_yaml_tests: $(YAML_TEST_DIR) $(YAML_TEST_TARGETS)
|
||||||
|
|
||||||
# runs a limited set of tests against a minimal config
|
# runs a limited set of tests against a minimal config
|
||||||
test: $(PY_SPEC_TARGETS)
|
test: $(PY_SPEC_TARGETS)
|
||||||
@ -43,6 +44,7 @@ $(PY_SPEC_DIR)/eth2/phase0/spec.py:
|
|||||||
python3 $(SCRIPT_DIR)/phase0/build_spec.py $(SPEC_DIR)/core/0_beacon-chain.md $@
|
python3 $(SCRIPT_DIR)/phase0/build_spec.py $(SPEC_DIR)/core/0_beacon-chain.md $@
|
||||||
|
|
||||||
|
|
||||||
|
CURRENT_DIR = ${CURDIR}
|
||||||
|
|
||||||
# The function that builds a set of suite files, by calling a generator for the given type (param 1)
|
# The function that builds a set of suite files, by calling a generator for the given type (param 1)
|
||||||
define build_yaml_tests
|
define build_yaml_tests
|
||||||
@ -50,22 +52,19 @@ define build_yaml_tests
|
|||||||
# Create the output
|
# Create the output
|
||||||
mkdir -p $(YAML_TEST_DIR)$(1)
|
mkdir -p $(YAML_TEST_DIR)$(1)
|
||||||
|
|
||||||
# Create a virtual environment
|
# 1) Create a virtual environment
|
||||||
python3 -m venv $(VENV_DIR)$(1)
|
# 2) Activate the venv, this is where dependencies are installed for the generator
|
||||||
# Activate the venv, this is where dependencies are installed for the generator
|
# 3) Install all the necessary requirements
|
||||||
. $(GENERATOR_VENVS_DIR)$(1)bin/activate
|
# 4) Run the generator. The generator is assumed to have an "main.py" file.
|
||||||
# Install all the necessary requirements
|
# 5) We output to the tests dir (generator program should accept a "-o <filepath>" argument.
|
||||||
pip3 install -r $(GENERATOR_DIR)$(1)requirements.txt
|
cd $(GENERATOR_DIR)$(1); python3 -m venv venv; . venv/bin/activate; pip3 install -r requirements.txt; python3 main.py -o $(CURRENT_DIR)/$(YAML_TEST_DIR)$(1)
|
||||||
|
|
||||||
# Run the generator. The generator is assumed to have an "main.py" file.
|
|
||||||
# We output to the tests dir (generator program should accept a "-p <filepath>" argument.
|
|
||||||
python3 $(GENERATOR_DIR)$(1)main.py -o $(YAML_TEST_DIR)$(1)
|
|
||||||
$(info generator $(1) finished)
|
$(info generator $(1) finished)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# The tests dir itself is simply build by creating the directory (recursively creating deeper directories if necessary)
|
# The tests dir itself is simply build by creating the directory (recursively creating deeper directories if necessary)
|
||||||
$(YAML_TEST_DIR):
|
$(YAML_TEST_DIR):
|
||||||
$(info ${YAML_TEST_TARGETS})
|
$(info creating directory, to output yaml targets to: ${YAML_TEST_TARGETS})
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
# For any target within the tests dir, build it using the build_yaml_tests function.
|
# For any target within the tests dir, build it using the build_yaml_tests function.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user