Skip to content

Commit

Permalink
feat(ccode_runner): refactor cpast into ccode refactor and cli
Browse files Browse the repository at this point in the history
  • Loading branch information
rootCircle committed Oct 3, 2024
1 parent 50fc7f0 commit 1b9cd0d
Show file tree
Hide file tree
Showing 17 changed files with 277 additions and 482 deletions.
701 changes: 246 additions & 455 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [
"clex",
"cpastord"
# "clex_llm",
, "cscrapper", "clex_llm"]
, "cscrapper", "clex_llm", "ccode_runner"]
resolver = "2"

[profile.dev]
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,11 @@ clippy :
# make test

test :
cargo test --all-features

CFLAGS="" CXXFLAGS="" cargo test --all-features

# Run format clippy test and tests.
#
# Usage :
# make precommit

precommit :
cargo fmt --all --check && cargo clippy --all-features --all-targets -- -D warnings && cargo test --all-features
precommit : fmt clippy test
8 changes: 8 additions & 0 deletions ccode_runner/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "ccode_runner"
version = "0.1.0"
edition = "2021"

[dependencies]
which = "6.0.3"

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub(crate) mod program_store;
pub mod program_store;
mod runner;
pub(crate) mod runner_error_types;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::error::Error;
use std::path::Path;

#[derive(Debug)]
pub(crate) struct ProgramStore {
pub struct ProgramStore {
correct_file: Language,
test_file: Language,
correct_file_bin_path: String,
Expand All @@ -19,7 +19,7 @@ enum FileType {
}

impl ProgramStore {
pub(crate) fn new(
pub fn new(
correct_file: &Path,
test_file: &Path,
do_force_compile: bool,
Expand Down Expand Up @@ -47,7 +47,7 @@ impl ProgramStore {
correct_file.exists() && test_file.exists()
}

pub(crate) fn run_codes_and_compare_output(
pub fn run_codes_and_compare_output(
&self,
stdin_content: &str,
) -> Result<(bool, String, String), &str> {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions ccode_runner/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod lang_runner;
mod utils;
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions cpast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ default-run = "cpast"
[dependencies]
clap = { version = "4.5.16", features = ["derive"] }
cli-clipboard = { version = "0.4.0", optional = true }
which = "6.0.3"
tokio = { version = "1.39.3", features = ["full"] }
tokio = { version = "1.40.0", features = ["full"] }
futures = "0.3.30"
colored = "2.1.0"
clap_complete = "4.5.24"
clap_complete = "4.5.32"
clex = { path = "../clex" }
ccode_runner = { path = "../ccode_runner" }

[features]
default = ["clipboard"]
Expand Down
2 changes: 2 additions & 0 deletions cpast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ cpast test -c correct.cpp -t incorrect.cpp -g "(N) (?:N){\1}" --iterations 100
* `(N) (?:N){\1}` is the language generator.
* `100` is the number of test iterations.

`CPAST_DEBUG=1 cpast test ...` can be used to debug the test cases generated.

#### generate

```bash
Expand Down
5 changes: 1 addition & 4 deletions cpast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,14 @@
//! For more details on usage and advanced features, refer to the README.
//!
mod lang_runner;
mod utils;

use colored::Colorize;
use futures::future::join_all;
use std::env;
use std::path::Path;
use std::process::exit;
use std::sync::{Arc, Mutex};

use crate::lang_runner::program_store::ProgramStore;
use ccode_runner::lang_runner::program_store::ProgramStore;
use clex::clex_language::clex_error_type::ClexErrorType;
use clex::clex_language::parser::Parser;
use clex::clex_language::{code_generator, lexer, parser};
Expand Down
13 changes: 6 additions & 7 deletions cpastord/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = "1.0.66"
shuttle-serenity = "0.36.0"
shuttle-runtime = "0.36.0"
serenity = { version = "0.11.5", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] }
shuttle-secrets = "0.36.0"
tokio = "1.26.0"
tracing = "0.1.37"
anyhow = "1.0.89"
shuttle-serenity = "0.48.0"
shuttle-runtime = "0.48.0"
serenity = { version = "0.12.2", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] }
tokio = "1.40.0"
tracing = "0.1.40"
cpast = { path = "../cpast" }

6 changes: 2 additions & 4 deletions cpastord/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serenity::async_trait;
use serenity::model::channel::Message;
use serenity::model::gateway::Ready;
use serenity::prelude::*;
use shuttle_secrets::SecretStore;
use shuttle_runtime::{SecretStore, Secrets};
use tracing::{error, info};

struct Bot;
Expand All @@ -26,9 +26,7 @@ impl EventHandler for Bot {
}

#[shuttle_runtime::main]
async fn serenity(
#[shuttle_secrets::Secrets] secret_store: SecretStore,
) -> shuttle_serenity::ShuttleSerenity {
async fn serenity(#[Secrets] secret_store: SecretStore) -> shuttle_serenity::ShuttleSerenity {
// Get the discord token set in `Secrets.toml`
let token = if let Some(token) = secret_store.get("DISCORD_TOKEN") {
token
Expand Down

0 comments on commit 1b9cd0d

Please sign in to comment.