Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update CI #422

Merged
merged 1 commit into from
Oct 5, 2023
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
13 changes: 13 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion bot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static DATA: OnceLock<Data> = OnceLock::new();

#[tokio::main]
async fn main() -> Result<()> {
pretty_env_logger::init();
pretty_env_logger::init_timed();
let data = if cfg!(debug_assertions) {
Data::dynamic()
} else {
Expand Down
4 changes: 4 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ anyhow = "1.0"
tokio = { version = "1.32" , features = ["macros", "rt-multi-thread" ] }
const_format = "0.2"
regex = "1.9.5"

[dev-dependencies]
env_logger = "0.10"
test-log = "0.2"
3 changes: 3 additions & 0 deletions core/src/model/finite_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ impl Fs {
next_states: options,
})
}
pub fn num_nodes(&self) -> usize {
1 + self.next_states.values().map(Fs::num_nodes).sum::<usize>()
}
}
40 changes: 24 additions & 16 deletions core/tests/test_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ fn test_fs(fs: Fs) -> Result<()> {
if fs.message.chars().all(char::is_whitespace) {
bail!("Empty message");
}
if fs.link.as_ref().is_some_and(|s| s.chars().all(char::is_whitespace)) {
if fs
.link
.as_ref()
.is_some_and(|s| s.chars().all(char::is_whitespace))
{
bail!("Empty link");
}
test_md(&fs.message)?;
Expand All @@ -39,27 +43,13 @@ fn test_fs(fs: Fs) -> Result<()> {
Ok(())
}

#[tokio::test]
async fn test_table() -> Result<()> {
let data = if cfg!(debug_assertions) {
get_data_from_web().await?
} else {
get_data_from_file("../table.csv")?
};
for fs in data.into_values() {
test_fs(fs)?;
}

Ok(())
}

// Add tests using cfg

#[cfg(test)]
mod tests {
use super::*;

#[test]
#[test_log::test]
fn test_example() -> Result<()> {
let s = r" *bold \*text*
_italic \*text_
Expand All @@ -76,4 +66,22 @@ pre-formatted fixed-width code block written in the Python programming language
``` ";
test_md(s)
}

#[test_log::test(tokio::test)]
async fn test_table() -> Result<()> {
let data = if cfg!(debug_assertions) {
get_data_from_web().await?
} else {
get_data_from_file("../table.csv")?
};
data.iter()
.for_each(|(lang, fs)| log::info!("Testing {lang} with {} nodes", fs.num_nodes()));
for (lang, fs) in data.into_iter() {
let n_nodes = fs.num_nodes();
test_fs(fs)?;
log::info!("All tests passed for {lang} with {n_nodes} nodes");
}

Ok(())
}
}
Loading