Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ indent_style = unset
[HELP.md]
max_line_length = 400
trim_trailing_whitespace = false

[*.stderr]
indent_size = unset
max_line_length = unset
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,16 @@ jobs:
run: cd butane_test_helper && cargo +stable test --all-features
- name: Test Core
run: cd butane_core && cargo +stable test --all-features
- name: Test Codegen
run: cd butane_codegen && cargo +stable test --all-features
- name: Test CLI
run: cd butane_cli && cargo +stable test --all-features
- name: Test
run: cargo +stable test -p butane_tests --all-features
- name: Test using trybuild
run: cargo +stable test -p trybuild_tests
- name: Test doctests
run: |
cargo +stable test -p butane_codegen --all-features
cargo +stable test -p butane --all-features
- name: Check example migrations have been updated
run: |
set -ex
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ butane.code_workspace.code-workspace
.vscode/tasks.json
butane_codegen/.butane
butane/tests/.butane
trybuild_tests/tests/Cargo.toml
db.sqlite
tmp_pg
*.db
15 changes: 14 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,23 @@ cargo test
Run tests for a specific package:

```bash
cargo test -p butane
cargo test -p butane_core
cargo test -p butane # doctests only
cargo test -p butane_tests
cargo test -p trybuild_tests
```

If you are enhancing `butane_codegen`, please create tests in [`trybuild_tests`](trybuild_tests/)
instead of `butane_codegen`.

## Development notes

There is a cyclic test dependency between `butane_test_helper` and `butane_core`.

`butane_test_helper` uses `butane_core` in its library.

`butane_core` uses `butane_test_helper` in its tests.

## Code Quality

Before submitting a PR, you may use the following commands locally to ensure that your code passes all checks:
Expand Down
133 changes: 132 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ members = [
"examples/getting_started",
"examples/getting_started_async",
"examples/reserved-words",
"trybuild_tests",
]

[workspace.package]
Expand Down
4 changes: 4 additions & 0 deletions butane_codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ syn = { workspace = true }

[lib]
proc-macro = true
# When `cargo test` & `cargo nextest run` are run at the top of the workspace,
# they fail if `test = true` here.
# See https://github.com/Electron100/butane/issues/419
test = false
6 changes: 3 additions & 3 deletions butane_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use syn::{Expr, Ident};

mod filter;

#[cfg(test)]
mod test_field_type;
// Note: butane_codegen is a proc-macro crate and cannot have unit tests
// Tests for derive macros should be in butane_core or integration tests

/// Attribute macro which marks a struct as being a data model and
/// generates an implementation of [`DataObject`](butane_core::DataObject). This
Expand Down Expand Up @@ -95,7 +95,7 @@ pub fn model(_args: TokenStream, input: TokenStream) -> TokenStream {
///
/// [`FieldType`]: crate::FieldType
/// [`Many`]: butane_core::many::Many
#[proc_macro_derive(DataObject, attributes(table, pk, unique, default, auto))]
#[proc_macro_derive(DataObject, attributes(table, pk, unique, default))]
pub fn derive_data_object(input: TokenStream) -> TokenStream {
codegen::derive_dataobject_with_migrations(input.into(), &mut migrations_for_dir()).into()
}
Expand Down
40 changes: 0 additions & 40 deletions butane_codegen/src/test_field_type.rs

This file was deleted.

26 changes: 26 additions & 0 deletions trybuild_tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This project member only contains tests that built using `trybuild`.
# These tests allow snapshotting of compiler errors and warnings to ensure that
# incorrect usage of macros fails as expected, and provides useful error messages.
# See the README.md in this directory for more information.
[package]
name = "trybuild_tests"
edition.workspace = true
license.workspace = true
repository.workspace = true
version.workspace = true
rust-version.workspace = true
autobenches = false
autobins = false
autoexamples = false

[lib]
doctest = false
test = false

[dependencies]

[dev-dependencies]
butane.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
trybuild = "1.0"
Loading
Loading