Skip to content

Commit

Permalink
Merge pull request #422 from anstadnik/update_CI
Browse files Browse the repository at this point in the history
update CI
  • Loading branch information
anstadnik authored Oct 5, 2023
2 parents 65deaba + b08bf4f commit 6890884
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 17 deletions.
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(())
}
}

0 comments on commit 6890884

Please sign in to comment.