Skip to content

Commit

Permalink
migrate to a single workspace
Browse files Browse the repository at this point in the history
Consolidate the build setup for all crates to use 2021-style cargo.toml
with workspaces.  Note that the `tests/` dir has an unusual setup,
where the tests dir is both a separate crate and a set of integration tests for the log crate.

I am not certain of all the interactions here, and making it into a
regular test crate breaks the filter test, so leaving as is for now
until someone can explain what's going on there.
  • Loading branch information
nyurik committed Aug 29, 2023
1 parent 242a982 commit 7ef5394
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ jobs:
- run: cargo test --verbose --features kv_unstable_sval
- run: cargo test --verbose --features kv_unstable_serde
- run: cargo test --verbose --features "kv_unstable kv_unstable_std kv_unstable_sval kv_unstable_serde"
- run: cargo run --verbose --manifest-path test_max_level_features/Cargo.toml
- run: cargo run --verbose --manifest-path test_max_level_features/Cargo.toml --release
- run: cargo run --verbose -p test_max_level_features
- run: cargo run --verbose -p test_max_level_features --release

rustfmt:
name: Rustfmt
Expand All @@ -61,10 +61,7 @@ jobs:
rustup update stable --no-self-update
rustup default stable
rustup component add rustfmt
# log repo does not use Cargo workspaces, so `cargo fmt` will not check all the code
# perhaps this should be changed in the future
- run: cargo fmt -- --check
- run: cargo fmt --manifest-path test_max_level_features/Cargo.toml -- --check
- run: cargo fmt --manifest-path tests/Cargo.toml -- --check

clippy:
Expand All @@ -78,7 +75,6 @@ jobs:
rustup default stable
rustup component add clippy
- run: cargo clippy --verbose
- run: cargo clippy --verbose --manifest-path test_max_level_features/Cargo.toml
- run: cargo clippy --verbose --manifest-path tests/Cargo.toml

doc:
Expand Down Expand Up @@ -135,6 +131,7 @@ jobs:
run: |
rustup update 1.60.0 --no-self-update
rustup default 1.60.0
- run: cargo test --verbose
- run: cargo test --verbose --manifest-path tests/Cargo.toml

embedded:
Expand Down
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[package]

name = "log"
version = "0.4.20" # remember to update html_root_url
authors = ["The Rust Project Developers"]
Expand Down Expand Up @@ -73,3 +72,9 @@ value-bag = { version = "1.4", features = ["test"] }
# By defining the crate as direct dependency we can increase it's minimal
# version making the minimal (crate) version CI happy.
proc-macro2 = { version = "1.0.63", default-features = false }

[workspace]
# TODO: the tests/ dir for historic reasons has a hacky setup as both tests/ dir and as tests crate.
# It breaks if it is added here, so this should be done at some later time
members = [".", "test_max_level_features"]
default-members = [".", "test_max_level_features"]
11 changes: 3 additions & 8 deletions test_max_level_features/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
[package]
name = "optimized"
name = "test_max_level_features"
version = "0.1.0"
edition = "2021"
publish = false

[[bin]]
name = "test_max_level_features"
path = "main.rs"

[dependencies.log]
path = ".."
features = ["max_level_debug", "release_max_level_info"]
[dependencies]
log = { path = "..", features = ["max_level_debug", "release_max_level_info"] }
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::sync::{Arc, Mutex};

#[cfg(feature = "std")]
use log::set_boxed_logger;

#[cfg(not(feature = "std"))]
fn set_boxed_logger(logger: Box<dyn Log>) -> Result<(), log::SetLoggerError> {
log::set_logger(Box::leak(logger))
Expand Down Expand Up @@ -44,21 +45,21 @@ fn main() {
fn test(a: &State, filter: LevelFilter) {
log::set_max_level(filter);
error!("");
last(&a, t(Level::Error, filter));
last(a, t(Level::Error, filter));
warn!("");
last(&a, t(Level::Warn, filter));
last(a, t(Level::Warn, filter));
info!("");
last(&a, t(Level::Info, filter));
last(a, t(Level::Info, filter));

debug!("");
if cfg!(debug_assertions) {
last(&a, t(Level::Debug, filter));
last(a, t(Level::Debug, filter));
} else {
last(&a, None);
last(a, None);
}

trace!("");
last(&a, None);
last(a, None);

fn t(lvl: Level, filter: LevelFilter) -> Option<Level> {
if lvl <= filter {
Expand Down
11 changes: 7 additions & 4 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# This is a hack, see comment in the root Cargo.toml
[workspace]

[package]
name = "integration"
version = "0.1.0"
Expand All @@ -8,8 +11,8 @@ build = "src/build.rs"
[features]
std = ["log/std"]

[dependencies.log]
path = ".."
[dependencies]
log = { path = ".." }

[dev-dependencies.rustversion]
version = "1.0"
[dev-dependencies]
rustversion = "1.0"

0 comments on commit 7ef5394

Please sign in to comment.