Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Unsplit and removal of *-internal crates #185

Merged
merged 18 commits into from
Aug 7, 2023

Conversation

iho
Copy link
Contributor

@iho iho commented Aug 1, 2023

this is fraction of #51

@iho iho requested review from frol and dj8yfo as code owners August 1, 2023 07:36
@iho iho marked this pull request as draft August 1, 2023 07:36
@dj8yfo dj8yfo changed the title Unsplit and removal of borsh-schema-derive-internal and borsh-schema-derive-internal crates Unsplit and removal of *-internal crates Aug 1, 2023
@dj8yfo
Copy link
Collaborator

dj8yfo commented Aug 1, 2023

  • the following is the target module structure for this pr:
# ❯ erd --pattern '.*\.rs' --suppress-size -y inverted
 borsh-derive
 └─ src
    ├─ internals.rs
    ├─ lib.rs
    └─ internals
       ├─ generics.rs
       ├─ serialize
       │  ├─ union
       │  │  └─ mod.rs
       │  ├─ struct
       │  │  └─ mod.rs
       │  ├─ mod.rs
       │  └─ enum
       │     └─ mod.rs
       ├─ schema
       │  ├─ struct
       │  │  └─ mod.rs
       │  ├─ mod.rs  # borsh-schema-derive-internal/src/schema_helpers.rs content => src/internals/schema/mod.rs,  
       │  └─ enum
       │     └─ mod.rs
       ├─ enum_discriminant_map.rs
       ├─ deserialize
       │  ├─ union
       │  │  └─ mod.rs
       │  ├─ struct
       │  │  └─ mod.rs
       │  ├─ mod.rs
       │  └─ enum
       │     └─ mod.rs
       ├─ attributes
       │  ├─ mod.rs
       │  ├─ field
       │  │  ├─ schema.rs
       │  │  ├─ schema
       │  │  │  └─ with_funcs.rs
       │  │  ├─ mod.rs
       │  │  └─ bounds.rs
       │  └─ parsing.rs
       └─ test_helpers.rs

The same outline is also present in this repo

@dj8yfo
Copy link
Collaborator

dj8yfo commented Aug 1, 2023

  • the following is the target tests modules structure of this pr:
 borsh-derive
 └──src
    ├──internals
    │  ├──attributes
    │  │  ├──field
    │  │  │  └──mod.rs
    │  │  │     └──#[cfg(test)]
    │  │  └──mod.rs
    │  │     └──#[cfg(test)]
    │  ├──deserialize
    │  │  ├──enum
    │  │  │  └──mod.rs
    │  │  │     └──#[cfg(test)]
    │  │  └──struct
    │  │     └──mod.rs
    │  │        └──#[cfg(test)]
    │  ├──schema
    │  │  ├──enum
    │  │  │  └──mod.rs
    │  │  │     └──#[cfg(test)]
    │  │  └──struct
    │  │     └──mod.rs
    │  │        └──#[cfg(test)]
    │  └──serialize
    │     ├──enum
    │     │  └──mod.rs
    │     │     └──#[cfg(test)]
    │     └──struct
    │        └──mod.rs
    │           └──#[cfg(test)]
    └──internals.rs
       └──#[cfg(test)]  # these aren't tests, it's `pub mod test_helpers;`

src/internals/attributes/field/mod.rs is needed instead of src/internals/attributes/field.rs , as insta crate has a nice feature of placing snapshots folder in the same folder as file containing tests, which create these snapshots,
so it will become src/internals/attributes/field/snapshots folder for tests in specifically src/internals/attributes/field/mod.rs,
which will allow to split up the total of 111 snapshots into small groups close to their corresponding tests.

@dj8yfo
Copy link
Collaborator

dj8yfo commented Aug 1, 2023

the following are some commands to simplify bookkeeping to make sure that probably all of tests/snapshots have been
transferred and not duplicated, though the module paths will change and strings for arguments of grep will too. (the initial version of this pr has transferred 36 borsh-schema-derive-internal snapshots twice, resulting in 147 snapshots total instead of 75 + 36 = 111)

  • borsh-derive-internal - 73 tests

    • cargo nextest list --features schema | grep attribute_helpers | wc -l # 25
    • cargo nextest list --features schema | grep enum_de | wc -l # 11
    • cargo nextest list --features schema | grep enum_ser | wc -l # 13
    • cargo nextest list --features schema | grep struct_de | wc -l # 11
    • cargo nextest list --features schema | grep struct_ser | wc -l # 13
  • borsh-schema-derive-internal - 36 tests

    • cargo nextest list --features schema | grep struct_schema | wc -l # 22
    • cargo nextest list --features schema | grep enum_schema | wc -l # 14
  • borsh-derive-internal - 75 snapshots

    • fd 'attribute_helpers.*\.snap' | wc -l # 27
    • fd 'enum_de.*\.snap' | wc -l # 11
    • fd 'enum_ser.*\.snap' | wc -l # 13
    • fd 'struct_de.*\.snap' | wc -l # 11
    • fd 'struct_ser.*\.snap' | wc -l # 13
  • borsh-schema-derive-internal - 36 snapshots

    • fd 'enum_schema.*\.snap' | wc -l # 14
    • fd 'struct_schema.*\.snap' | wc -l # 22

@iho
Copy link
Contributor Author

iho commented Aug 3, 2023

I changed structure, so you need to use different commands:

cargo nextest list --features schema 2>/dev/null| grep attributes | wc -l
cargo nextest list --features schema 2>/dev/null| grep deserialize::enums  | wc -l
cargo nextest list --features schema 2>/dev/null| grep internals::serialize::enums  | wc -l
cargo nextest list --features schema 2>/dev/null| grep deserialize::structs  | wc -l
cargo nextest list --features schema 2>/dev/null| grep internals::serialize::structs  | wc -l
echo #####

cargo nextest list --features schema 2>/dev/null| grep internals::schema::structs  | wc -l
cargo nextest list --features schema 2>/dev/null| grep  internals::schema::enums  | wc -l

echo #####
ls src/internals/attributes/item/snapshots | wc -l
ls src/internals/attributes/field/snapshots | wc -l

ls src/internals/deserialize/enums/snapshots | wc -l
ls src/internals/serialize/enums/snapshots | wc -l
ls src/internals/deserialize/structs/snapshots | wc -l
ls src/internals/serialize/structs/snapshots | wc -l
echo #####
ls src/internals/schema/enums/snapshots | wc -l
ls src/internals/schema/structs/snapshots | wc -l

@iho iho marked this pull request as ready for review August 3, 2023 12:27
borsh-derive/src/lib.rs Show resolved Hide resolved
borsh-derive/Cargo.toml Show resolved Hide resolved
@iho iho marked this pull request as draft August 3, 2023 20:07
@iho iho changed the title Unsplit and removal of *-internal crates refactor!:Unsplit and removal of *-internal crates Aug 3, 2023
@frol frol changed the title refactor!:Unsplit and removal of *-internal crates refactor!: Unsplit and removal of *-internal crates Aug 3, 2023
borsh-derive/src/internals/deserialize/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/schema/struct/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals.rs Outdated Show resolved Hide resolved
@dj8yfo
Copy link
Collaborator

dj8yfo commented Aug 4, 2023

Added commit to simplify potential funeral of schema feature (with honours and three-volley salute).

@dj8yfo dj8yfo force-pushed the iho_unsplit_borsh-derive-internal2 branch from b432f65 to 2fe3cfe Compare August 4, 2023 07:25
borsh-derive/Cargo.toml Show resolved Hide resolved
borsh-derive/src/internals/serialize/struct/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/serialize/struct/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/lib.rs Outdated Show resolved Hide resolved
borsh-derive/src/lib.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/schema/struct/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/schema/struct/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/schema/enum/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/deserialize/enum/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/deserialize/struct/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/lib.rs Show resolved Hide resolved
@iho iho marked this pull request as ready for review August 4, 2023 20:18
borsh-derive/src/lib.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/deserialize/enums/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/deserialize/mod.rs Outdated Show resolved Hide resolved
@iho iho marked this pull request as draft August 5, 2023 18:54
@dj8yfo dj8yfo requested a review from frol August 7, 2023 12:31
@frol frol marked this pull request as ready for review August 7, 2023 13:08
.github/test.sh Outdated Show resolved Hide resolved
@frol frol merged commit ae97a0f into near:master Aug 7, 2023
7 checks passed
@frol
Copy link
Collaborator

frol commented Aug 7, 2023

@iho Thanks for the dedicated work!

@dj8yfo Thanks for the thorough code reviews

This was referenced Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants