Skip to content

Commit

Permalink
feat: normalize crate names, new shared test utils (#3)
Browse files Browse the repository at this point in the history
* feat: normalize crate names, new shared test utils

* chore: remove residule
  • Loading branch information
pluveto authored Dec 15, 2023
1 parent 874c57f commit ad6198a
Show file tree
Hide file tree
Showing 27 changed files with 106 additions and 99 deletions.
39 changes: 21 additions & 18 deletions .versionrc.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
module.exports = {
bumpFiles: [
{
filename: './rulog-cli/Cargo.toml',
updater: './scripts/cargo-updater'
},
{
filename: './rulog-core/Cargo.toml',
const fs = require('fs');
const path = require('path');

function createEntries() {
const entries = fs.readdirSync('./')
.filter(name => name.startsWith('rulog_') && fs.lstatSync(name).isDirectory())
.map(name => ({
filename: `./${name}/Cargo.toml`,
updater: './scripts/cargo-updater'
},
{
filename: './rulog-vm/Cargo.toml',
updater: './scripts/cargo-updater'
},
{
filename: './package.json',
type: 'json'
}
],
}));

// Add the entry for package.json
entries.push({
filename: './package.json',
type: 'json'
});

return entries;
}

module.exports = {
bumpFiles: createEntries(),
};
28 changes: 19 additions & 9 deletions Cargo.lock

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

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[workspace]

members = [
"rulog-core",
"rulog-cli",
"rulog-vm",
"rulog_core",
"rulog_cli",
"rulog_vm",
"rulog_test_util",
]
14 changes: 0 additions & 14 deletions rulog-cli/Cargo.toml

This file was deleted.

12 changes: 0 additions & 12 deletions rulog-vm/Cargo.toml

This file was deleted.

10 changes: 10 additions & 0 deletions rulog_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "rulog_cli"
version = "0.1.2"
edition = "2021"

[dependencies]
env_logger = "0.10.1"
log = "0.4.20"
rulog_core = { path = "../rulog_core" }
rulog_vm = { path = "../rulog_vm" }
File renamed without changes.
10 changes: 10 additions & 0 deletions rulog_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "rulog_core"
version = "0.1.2"
edition = "2021"

[dependencies]
env_logger = "0.10.1"
log = "0.4.20"
backtrace = "0.3"
rulog_test_util = { path = "../rulog_test_util" }
12 changes: 2 additions & 10 deletions rulog-core/src/lexer.rs → rulog_core/src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,9 @@ impl<'a> Lexer<'a> {
}
#[cfg(test)]
mod tests {
use crate::types::token::Token;

use super::*;

fn setup_logger() {
use log::LevelFilter;
let _ = env_logger::builder()
.is_test(true)
.filter_level(LevelFilter::Trace)
.try_init();
}
use crate::types::token::Token;
use rulog_test_util::setup_logger;

#[test]
fn test_next_token() {
Expand Down
File renamed without changes.
9 changes: 1 addition & 8 deletions rulog-core/src/parser.rs → rulog_core/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,7 @@ mod tests {
use crate::types::ast::Float;

use super::*;

fn setup_logger() {
use log::LevelFilter;
let _ = env_logger::builder()
.is_test(true)
.filter_level(LevelFilter::Trace)
.try_init();
}
use rulog_test_util::setup_logger;

//===------------------------------------------------------------------===//
// Sub-parser tests
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 5 additions & 6 deletions rulog-core/Cargo.toml → rulog_test_util/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[package]
name = "rulog_test_util"
version = "0.1.2"
edition = "2021"

[dependencies]
env_logger = "0.10.1"
log = "0.4.20"
backtrace = "0.3"

[package]
name = "rulog-core"
version = "0.1.3"
edition = "2021"
19 changes: 19 additions & 0 deletions rulog_test_util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::io::Write;

pub fn setup_logger() {
use log::LevelFilter;
let _ = env_logger::builder()
.is_test(true)
.format(|buf, record| {
writeln!(
buf,
"[{}] {}:{} \t - {}",
record.level(),
record.file().unwrap_or("unknown"),
record.line().unwrap_or(0),
record.args()
)
})
.filter_level(LevelFilter::Trace)
.try_init();
}
14 changes: 14 additions & 0 deletions rulog_vm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "rulog_vm"
version = "0.1.2"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
chrono = "0.4.31"
env_logger = "0.10.1"
log = "0.4.20"
rulog_test_util = { path = "../rulog_test_util" }
[dependencies.rulog_core]
path = "../rulog_core"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 1 addition & 19 deletions rulog-vm/src/interpreter.rs → rulog_vm/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,7 @@ impl Interpreter {
#[cfg(test)]
mod tests {
use super::*;
use std::io::Write;

fn setup_logger() {
use log::LevelFilter;
let _ = env_logger::builder()
.is_test(true)
.format(|buf, record| {
writeln!(
buf,
"{}:{} \t[{}] - {}",
record.file().unwrap_or("unknown"),
record.line().unwrap_or(0),
record.level(),
record.args()
)
})
.filter_level(LevelFilter::Trace)
.try_init();
}
use rulog_test_util::setup_logger;

#[test]
fn test_parent_true() {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit ad6198a

Please sign in to comment.