everything compiles

This commit is contained in:
Christoph J. Scherr 2023-09-20 14:52:22 +02:00
parent fa6eb387ce
commit 3c8a2d9661
16 changed files with 58 additions and 293 deletions

View File

@ -1,6 +1,5 @@
[workspace] [workspace]
resolver = "2" resolver = "2"
publish = false
members = [ members = [
"members/pt", "members/pt",
"members/pt-core", "members/pt-core",
@ -22,8 +21,6 @@ default-members = [
] ]
[workspace.package] [workspace.package]
publish = false publish = false
default-run = "pt"
name = "libpt"
version = "0.1.7" version = "0.1.7"
edition = "2021" edition = "2021"
authors = ["Christoph J. Scherr <software@cscherr.de>"] authors = ["Christoph J. Scherr <software@cscherr.de>"]

View File

@ -1 +1,2 @@
use pt_core;
pub mod datalayout; pub mod datalayout;

View File

@ -1,14 +1,41 @@
pub fn add(left: usize, right: usize) -> usize { //! # very short description
left + right //!
} //! Short description
//!
//! Details
//!
//! ## Section 1
//!
//! ## Section 2
#[cfg(test)] //// ATTRIBUTES ////////////////////////////////////////////////////////////////////////////////////
mod tests { // we want docs
use super::*; #![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] //// IMPORTS ///////////////////////////////////////////////////////////////////////////////////////
fn it_works() { pub mod calculator;
let result = add(2, 2);
assert_eq!(result, 4); //// TYPES /////////////////////////////////////////////////////////////////////////////////////////
}
} //// CONSTANTS /////////////////////////////////////////////////////////////////////////////////////
//// STATICS ///////////////////////////////////////////////////////////////////////////////////////
//// MACROS ////////////////////////////////////////////////////////////////////////////////////////
//// ENUMS /////////////////////////////////////////////////////////////////////////////////////////
//// STRUCTS ///////////////////////////////////////////////////////////////////////////////////////
//// IMPLEMENTATION ////////////////////////////////////////////////////////////////////////////////
//// PUBLIC FUNCTIONS //////////////////////////////////////////////////////////////////////////////
//// PRIVATE FUNCTIONS /////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,47 +1,24 @@
[package] [package]
default-run = "pt"
name = "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 # 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] [dependencies]
clap = { version = "4.3.11", features = ["derive"] } pt-bintols = { version = "0.1.0", path = "../pt-bintols" }
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-core = { version = "0.1.0", path = "../pt-core" } pt-core = { version = "0.1.0", path = "../pt-core" }
pt-hedu = { version = "0.1.0", path = "../pt-hedu" } pt-hedu = { version = "0.1.0", path = "../pt-hedu" }
pt-log = { version = "0.1.0", path = "../pt-log" } pt-log = { version = "0.1.0", path = "../pt-log" }
pt-math = { version = "0.1.0", path = "../pt-math" } pt-math = { version = "0.1.0", path = "../pt-math" }
pt-net = { version = "0.1.0", path = "../pt-net" } pt-net = { version = "0.1.0", path = "../pt-net" }
regex = "1.9.1" pt-ccc = { version = "0.1.0", path = "../pt-ccc" }
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"

View File

@ -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_core;
pub use pt_log; pub use pt_bintols;
pub use pt_net;
pub use pt_hedu; pub use pt_hedu;
pub use pt_log;
pub use pt_math;
pub use pt_net;
pub use pt_ccc;

View File

@ -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 /////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -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 /////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -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())
}

View File

@ -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()

View File

@ -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()

View File

@ -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");
}