From 3c8a2d966196aeaeab6413575c7324493b0c78ec Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Wed, 20 Sep 2023 14:52:22 +0200 Subject: [PATCH] everything compiles --- Cargo.toml | 3 - members/pt-bintols/src/lib.rs | 1 + .../math => pt-math/src}/calculator/base.rs | 0 .../math => pt-math/src}/calculator/mod.rs | 0 .../math => pt-math/src}/calculator/term.rs | 0 members/pt-math/src/lib.rs | 51 ++++++++--- members/pt/Cargo.toml | 49 +++-------- members/pt/src/lib.rs | 30 ++----- members/pt/src/math/mod.rs | 41 --------- members/pt/src/template.rs | 40 --------- members/pt/tests/bin.rs | 0 members/pt/tests/lib.rs | 12 --- members/pt/tests/python/__init__.py | 0 members/pt/tests/python/lib.py | 15 ---- members/pt/tests/python/test_logger.py | 21 ----- members/pt/tests/test_logger_struct.rs | 88 ------------------- 16 files changed, 58 insertions(+), 293 deletions(-) rename members/{pt/src/math => pt-math/src}/calculator/base.rs (100%) rename members/{pt/src/math => pt-math/src}/calculator/mod.rs (100%) rename members/{pt/src/math => pt-math/src}/calculator/term.rs (100%) delete mode 100644 members/pt/src/math/mod.rs delete mode 100644 members/pt/src/template.rs delete mode 100644 members/pt/tests/bin.rs delete mode 100644 members/pt/tests/lib.rs delete mode 100644 members/pt/tests/python/__init__.py delete mode 100644 members/pt/tests/python/lib.py delete mode 100644 members/pt/tests/python/test_logger.py delete mode 100644 members/pt/tests/test_logger_struct.rs diff --git a/Cargo.toml b/Cargo.toml index afca6f7..5689c94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,5 @@ [workspace] resolver = "2" -publish = false members = [ "members/pt", "members/pt-core", @@ -22,8 +21,6 @@ default-members = [ ] [workspace.package] publish = false -default-run = "pt" -name = "libpt" version = "0.1.7" edition = "2021" authors = ["Christoph J. Scherr "] diff --git a/members/pt-bintols/src/lib.rs b/members/pt-bintols/src/lib.rs index 564192b..a058ad3 100644 --- a/members/pt-bintols/src/lib.rs +++ b/members/pt-bintols/src/lib.rs @@ -1 +1,2 @@ +use pt_core; pub mod datalayout; diff --git a/members/pt/src/math/calculator/base.rs b/members/pt-math/src/calculator/base.rs similarity index 100% rename from members/pt/src/math/calculator/base.rs rename to members/pt-math/src/calculator/base.rs diff --git a/members/pt/src/math/calculator/mod.rs b/members/pt-math/src/calculator/mod.rs similarity index 100% rename from members/pt/src/math/calculator/mod.rs rename to members/pt-math/src/calculator/mod.rs diff --git a/members/pt/src/math/calculator/term.rs b/members/pt-math/src/calculator/term.rs similarity index 100% rename from members/pt/src/math/calculator/term.rs rename to members/pt-math/src/calculator/term.rs diff --git a/members/pt-math/src/lib.rs b/members/pt-math/src/lib.rs index 7d12d9a..0a4de71 100644 --- a/members/pt-math/src/lib.rs +++ b/members/pt-math/src/lib.rs @@ -1,14 +1,41 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right -} +//! # very short description +//! +//! Short description +//! +//! Details +//! +//! ## Section 1 +//! +//! ## Section 2 -#[cfg(test)] -mod tests { - use super::*; +//// ATTRIBUTES //////////////////////////////////////////////////////////////////////////////////// +// we want docs +#![warn(missing_docs)] +#![warn(rustdoc::missing_crate_level_docs)] +// we want Debug everywhere. +#![warn(missing_debug_implementations)] +// enable clippy's extra lints, the pedantic version +#![warn(clippy::pedantic)] - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} +//// IMPORTS /////////////////////////////////////////////////////////////////////////////////////// +pub mod calculator; + +//// TYPES ///////////////////////////////////////////////////////////////////////////////////////// + +//// CONSTANTS ///////////////////////////////////////////////////////////////////////////////////// + +//// STATICS /////////////////////////////////////////////////////////////////////////////////////// + +//// MACROS //////////////////////////////////////////////////////////////////////////////////////// + +//// ENUMS ///////////////////////////////////////////////////////////////////////////////////////// + +//// STRUCTS /////////////////////////////////////////////////////////////////////////////////////// + +//// IMPLEMENTATION //////////////////////////////////////////////////////////////////////////////// + +//// PUBLIC FUNCTIONS ////////////////////////////////////////////////////////////////////////////// + +//// PRIVATE FUNCTIONS ///////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/members/pt/Cargo.toml b/members/pt/Cargo.toml index 4add354..cbfebe8 100644 --- a/members/pt/Cargo.toml +++ b/members/pt/Cargo.toml @@ -1,47 +1,24 @@ [package] -default-run = "pt" name = "pt" -version = "0.1.0" +publish.workspace = true +version.workspace = true +edition.workspace = true +authors.workspace = true +license.workspace = true +description.workspace = true +readme.workspace = true +homepage.workspace = true +repository.workspace = true +keywords.workspace = true +categories.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -name = "pt" -crate-type = ["cdylib", "rlib"] -path = "src/lib.rs" - -[[bin]] -name = "pt" -path = "../members/pt-bin/src/main/mod.rs" - -[[bin]] -name = "ccc" -path = "../members/pt-bin/src/ccc/mod.rs" - [dependencies] -clap = { version = "4.3.11", features = ["derive"] } -clap-num = "1.0.2" -clap-verbosity-flag = "2.0.1" -env_logger = "0.10.0" -humantime = "2.1.0" -num = "0.4.0" -num-traits = "0.2.16" -openssl = "0.10.55" -openssl-sys = "0.9.90" -pt-bin = { version = "0.1.0", path = "../pt-bin" } +pt-bintols = { version = "0.1.0", path = "../pt-bintols" } pt-core = { version = "0.1.0", path = "../pt-core" } pt-hedu = { version = "0.1.0", path = "../pt-hedu" } pt-log = { version = "0.1.0", path = "../pt-log" } pt-math = { version = "0.1.0", path = "../pt-math" } pt-net = { version = "0.1.0", path = "../pt-net" } -regex = "1.9.1" -reqwest = { version = "0.11.18", features = ["blocking"] } -serde = { version = "1.0.171", features = ["derive"] } -serde_json = "1.0.102" -signal-hook = "0.3.15" -tracing = "0.1.37" -tracing-appender = "0.2.2" -tracing-subscriber = "0.3.17" - -[dev-dependencies] -gag = "1.0.0" +pt-ccc = { version = "0.1.0", path = "../pt-ccc" } diff --git a/members/pt/src/lib.rs b/members/pt/src/lib.rs index fc9bbff..185eda7 100644 --- a/members/pt/src/lib.rs +++ b/members/pt/src/lib.rs @@ -1,27 +1,7 @@ -//! # `libpt` -//! -//! [`libpt`](crate) contains my personal code. It is compiled as all of the following: -//! -//! - dynamic library (`cdylib`, `.so` file on Linux) -//! - rust library crate (`rlib`, usable as ) -//! - python module (with [`PyO3`](pyo3)) -//! - executable (as `pt`) -//! -//! For more info on the linkage types, please refer to the -//! [rust reference](https://doc.rust-lang.org/reference/linkage.html). - -//// ATTRIBUTES //////////////////////////////////////////////////////////////////////////////////// -// we want docs -#![warn(missing_docs)] -#![warn(rustdoc::missing_crate_level_docs)] -// we want Debug everywhere. This is a library and there will be many bugs. -#![warn(missing_debug_implementations)] -// enable clippy's extra lints, the pedantic version -#![warn(clippy::pedantic)] - -//// IMPORTS /////////////////////////////////////////////////////////////////////////////////////// -/// contains useful code, such as macros, for general use pub use pt_core; -pub use pt_log; -pub use pt_net; +pub use pt_bintols; pub use pt_hedu; +pub use pt_log; +pub use pt_math; +pub use pt_net; +pub use pt_ccc; diff --git a/members/pt/src/math/mod.rs b/members/pt/src/math/mod.rs deleted file mode 100644 index 0a4de71..0000000 --- a/members/pt/src/math/mod.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! # very short description -//! -//! Short description -//! -//! Details -//! -//! ## Section 1 -//! -//! ## Section 2 - -//// ATTRIBUTES //////////////////////////////////////////////////////////////////////////////////// -// we want docs -#![warn(missing_docs)] -#![warn(rustdoc::missing_crate_level_docs)] -// we want Debug everywhere. -#![warn(missing_debug_implementations)] -// enable clippy's extra lints, the pedantic version -#![warn(clippy::pedantic)] - -//// IMPORTS /////////////////////////////////////////////////////////////////////////////////////// -pub mod calculator; - -//// TYPES ///////////////////////////////////////////////////////////////////////////////////////// - -//// CONSTANTS ///////////////////////////////////////////////////////////////////////////////////// - -//// STATICS /////////////////////////////////////////////////////////////////////////////////////// - -//// MACROS //////////////////////////////////////////////////////////////////////////////////////// - -//// ENUMS ///////////////////////////////////////////////////////////////////////////////////////// - -//// STRUCTS /////////////////////////////////////////////////////////////////////////////////////// - -//// IMPLEMENTATION //////////////////////////////////////////////////////////////////////////////// - -//// PUBLIC FUNCTIONS ////////////////////////////////////////////////////////////////////////////// - -//// PRIVATE FUNCTIONS ///////////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/members/pt/src/template.rs b/members/pt/src/template.rs deleted file mode 100644 index dac9d32..0000000 --- a/members/pt/src/template.rs +++ /dev/null @@ -1,40 +0,0 @@ -//! # very short description -//! -//! Short description -//! -//! Details -//! -//! ## Section 1 -//! -//! ## Section 2 - -//// ATTRIBUTES //////////////////////////////////////////////////////////////////////////////////// -// we want docs -#![warn(missing_docs)] -#![warn(rustdoc::missing_crate_level_docs)] -// we want Debug everywhere. -#![warn(missing_debug_implementations)] -// enable clippy's extra lints, the pedantic version -#![warn(clippy::pedantic)] - -//// IMPORTS /////////////////////////////////////////////////////////////////////////////////////// - -//// TYPES ///////////////////////////////////////////////////////////////////////////////////////// - -//// CONSTANTS ///////////////////////////////////////////////////////////////////////////////////// - -//// STATICS /////////////////////////////////////////////////////////////////////////////////////// - -//// MACROS //////////////////////////////////////////////////////////////////////////////////////// - -//// ENUMS ///////////////////////////////////////////////////////////////////////////////////////// - -//// STRUCTS /////////////////////////////////////////////////////////////////////////////////////// - -//// IMPLEMENTATION //////////////////////////////////////////////////////////////////////////////// - -//// PUBLIC FUNCTIONS ////////////////////////////////////////////////////////////////////////////// - -//// PRIVATE FUNCTIONS ///////////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/members/pt/tests/bin.rs b/members/pt/tests/bin.rs deleted file mode 100644 index e69de29..0000000 diff --git a/members/pt/tests/lib.rs b/members/pt/tests/lib.rs deleted file mode 100644 index 658af0e..0000000 --- a/members/pt/tests/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -/// # tests for the general behaviour of the libraries availability -/// -/// These tests will not go very in depth - -// IMPORTS ///////////////////////////////////////////////////////////////////////////////////////// -use pt; - -/// ## check if pt is loaded -#[test] -fn test_pt_is_loaded() { - assert!(pt::is_loaded()) -} diff --git a/members/pt/tests/python/__init__.py b/members/pt/tests/python/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/members/pt/tests/python/lib.py b/members/pt/tests/python/lib.py deleted file mode 100644 index 2ed4dc7..0000000 --- a/members/pt/tests/python/lib.py +++ /dev/null @@ -1,15 +0,0 @@ -""" -tests for the general behaviour of the libraries availability -""" -import unittest -import libpt - -class TestLibptGeneral(unittest.TestCase): - - def test_loaded(self): - assert libpt.is_loaded() - -if __name__ == '__main__': - unittest.main() - - diff --git a/members/pt/tests/python/test_logger.py b/members/pt/tests/python/test_logger.py deleted file mode 100644 index c13c7c7..0000000 --- a/members/pt/tests/python/test_logger.py +++ /dev/null @@ -1,21 +0,0 @@ -""" -test the logger -""" -import unittest -from libpt import logger - -class TestLogger(unittest.TestCase): - - def test_basic_logging(self): - logger.Logger.init() - l = logger.Logger() - l.trace("MSG") - l.debug("MSG") - l.info("MSG") - l.warn("MSG") - l.error("MSG") - -if __name__ == '__main__': - unittest.main() - - diff --git a/members/pt/tests/test_logger_struct.rs b/members/pt/tests/test_logger_struct.rs deleted file mode 100644 index 805da11..0000000 --- a/members/pt/tests/test_logger_struct.rs +++ /dev/null @@ -1,88 +0,0 @@ -//! # Tests for pt::logger::Logger -//! -//! Note: the module uses a global variable to store if the thread has -//// IMPORTS /////////////////////////////////////////////////////////////////////////////////////// -use pt::common::macros::get_stdout_for; -/// ## Tests for basic logging functionality -use pt::logger::*; - -use regex::Regex; - -use std::sync::Once; - -//// HELPERS /////////////////////////////////////////////////////////////////////////////////////// -static SETUP: Once = Once::new(); -// only initialize once -/// ## setup that's needed before testing the logger struct -fn setup() { - SETUP.call_once(|| { - // we don't want to log messages during our tests! - Logger::init_customized( - false, - std::path::PathBuf::from("/dev/null"), - false, - false, - true, - false, - tracing::Level::TRACE, - false, - false, - false, - ) - .expect("could not initialize Logger"); - println!() - }); -} - -//// IMPLEMENTATION //////////////////////////////////////////////////////////////////////////////// - -/// ## Tests for basic logging -/// -/// This test tests if the loggers basic logging functionality works, that is it's methods: -/// -/// - [`Logger::trace`] -/// - [`Logger::debug`] -/// - [`Logger::info`] -/// - [`Logger::warn`] -/// - [`Logger::error`] -/// -/// After those methods have Successfully been executed, their outputs gets stored in a single -/// [`String`] and a [`Regex`] checks if we have five correctly formatted messages. -#[test] -fn test_log_basic() { - setup(); - let l = Logger::new(); - let trace_out = get_stdout_for!(l.trace("MSG")); - let debug_out = get_stdout_for!(l.debug("MSG")); - let info_out = get_stdout_for!(l.info("MSG")); - let warn_out = get_stdout_for!(l.warn("MSG")); - let error_out = get_stdout_for!(l.error("MSG")); - let combined = format!( - "{}{}{}{}{}", - trace_out, debug_out, info_out, warn_out, error_out - ); - print!("{}", combined); - - // too long, so i split into two lines. - // this matches the format of the env_logger perfectly, but make sure that color is off, - // else the ANSI escape sequences break this test - let regex = Regex::new(concat!( - r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}Z\s+(TRACE|DEBUG|INFO|WARN|ERROR)\sMSG" - )) - .unwrap(); - - // we have 5 log levels, therefore we should have 5 captures - assert_eq!(regex.captures_iter(&combined).count(), 5); -} - -#[test] -fn test_multi_initialize() { - setup(); - let l = Logger::new(); - // these should be ignored due to the global flag - Logger::init(None, None).unwrap_err(); - Logger::init(None, None).unwrap_err(); - Logger::init(None, None).unwrap_err(); - Logger::init(None, None).unwrap_err(); - l.info("Successfully ignored extra init"); -}