Skip to content

Commit

Permalink
Merge pull request #205 from ralexstokes/refactor-gen-tools
Browse files Browse the repository at this point in the history
refactor test gen to its own package
  • Loading branch information
ralexstokes authored Jul 16, 2023
2 parents d510f75 + 44218ee commit 4d883a7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ resolver = "2"

members = [
"ethereum-consensus",
"ethereum-consensus-test-gen",
]
12 changes: 12 additions & 0 deletions ethereum-consensus-test-gen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "ethereum-consensus-test-gen"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"
readme = "./README.md"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
convert_case = "0.6.0"
walkdir = "2.3.3"
3 changes: 3 additions & 0 deletions ethereum-consensus-test-gen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `gen-tests`

Generates `rustc` tests that correspond to each test case in the `consensus-spec-tests`.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![doc(hidden)]

use convert_case::{Case, Casing};
use std::{
collections::HashMap,
Expand Down Expand Up @@ -1387,7 +1389,7 @@ fn main() {

println!("collected {collected_test_case_count} tests");

let generated_test_root = PathBuf::from("tests/consensus_spec_tests");
let generated_test_root = PathBuf::from("ethereum-consensus/tests/consensus_spec_tests");
fs::remove_dir_all(&generated_test_root).unwrap();

fs::create_dir_all(&generated_test_root).unwrap();
Expand Down
8 changes: 0 additions & 8 deletions ethereum-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ serde = ["dep:serde", "hex", "serde_json", "serde_yaml"]
async = ["tokio", "tokio-stream", "async-stream"]
spec-tests = ["serde", "serde_yaml"]
gen-spec = ["syn", "prettyplease", "quote"]
gen-tests = ["walkdir", "convert_case"]

[dependencies]
ssz_rs = "0.9.0"
Expand All @@ -37,8 +36,6 @@ syn = { version = "1.0.98", features = ["full", "visit", "visit-mut", "extra-tra
prettyplease = { version = "0.1.10", optional = true }
quote = { version = "1.0.18", optional = true }

walkdir = { version = "2.3.2", optional = true }
convert_case = { version = "0.5.0", optional = true }
bs58 = "0.4.0"

[dev-dependencies]
Expand All @@ -49,8 +46,3 @@ snap = "1"
name = "gen-spec"
path = "src/bin/gen_spec.rs"
required-features = ["gen-spec"]

[[bin]]
name = "gen-tests"
path = "src/bin/gen_tests.rs"
required-features = ["gen-tests"]
4 changes: 0 additions & 4 deletions ethereum-consensus/src/bin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@
Generates Rust source of future forks of the consensus spec based on prior forks.

Ping @ralexstokes if you need help here, this works but it is quite bespoke code and could be refined so it is easier to maintain and extend.

# `gen-tests`

Generates `rustc` tests that correspond to each test case in the `consensus-spec-tests`.

0 comments on commit 4d883a7

Please sign in to comment.