Compare commits
No commits in common. "5cc9ebe989cb754917c5cc3660deda8b6864ab0a" and "b4b5989f858af8954fc6d8707ddc634d242665f6" have entirely different histories.
5cc9ebe989
...
b4b5989f85
|
@ -96,40 +96,12 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "equivalent"
|
|
||||||
version = "1.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hashbrown"
|
|
||||||
version = "0.14.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "indexmap"
|
|
||||||
version = "2.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f"
|
|
||||||
dependencies = [
|
|
||||||
"equivalent",
|
|
||||||
"hashbrown",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "itoa"
|
|
||||||
version = "1.0.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.76"
|
version = "1.0.76"
|
||||||
|
@ -148,45 +120,6 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ryu"
|
|
||||||
version = "1.0.16"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde"
|
|
||||||
version = "1.0.195"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02"
|
|
||||||
dependencies = [
|
|
||||||
"serde_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_derive"
|
|
||||||
version = "1.0.195"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_yaml"
|
|
||||||
version = "0.9.30"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b1bf28c79a99f70ee1f1d83d10c875d2e70618417fda01ad1785e027579d9d38"
|
|
||||||
dependencies = [
|
|
||||||
"indexmap",
|
|
||||||
"itoa",
|
|
||||||
"ryu",
|
|
||||||
"serde",
|
|
||||||
"unsafe-libyaml",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
|
@ -209,8 +142,6 @@ name = "tester"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"serde",
|
|
||||||
"serde_yaml",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -219,12 +150,6 @@ version = "1.0.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unsafe-libyaml"
|
|
||||||
version = "0.2.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utf8parse"
|
name = "utf8parse"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
|
|
|
@ -7,5 +7,3 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.4.16", features = ["derive"] }
|
clap = { version = "4.4.16", features = ["derive"] }
|
||||||
serde = { version = "1.0.195", features = ["derive"] }
|
|
||||||
serde_yaml = "0.9.30"
|
|
||||||
|
|
70
README.md
70
README.md
|
@ -1,70 +0,0 @@
|
||||||
# Tester CMPUT 415 (rust version)
|
|
||||||
|
|
||||||
This is a (mostly) drop-in replacement for the previous tester written for CMPUT 415.
|
|
||||||
|
|
||||||
Most of the options are specified in the [config file](#configuration-file), so the cli is minimal. We do specify some options:
|
|
||||||
``` rust
|
|
||||||
Usage: tester [OPTIONS] --config-file <CONFIG> <COMMAND>
|
|
||||||
|
|
||||||
Commands:
|
|
||||||
validate Validate test matching and config file correctness
|
|
||||||
run Run all tests
|
|
||||||
grade Grade with grading config
|
|
||||||
help Print this message or the help of the given subcommand(s)
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-v, --verbosity... Sets the verbosity of the tester
|
|
||||||
-c, --config-file <CONFIG> Set the config file
|
|
||||||
-g, --grading-conf <GRADING_CONFIG> Set the grading config file
|
|
||||||
-h, --help Print help
|
|
||||||
-V, --version Print version
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
the verbosity defines the level of logging, you can play around with it (specify `-v[v]+` for more verbose logging).
|
|
||||||
|
|
||||||
## Configuration File
|
|
||||||
|
|
||||||
The configuration file is specified in [YAML](https://yaml.org/spec/1.2.2/), so go check it out. Below is a fully featured config file, with more to come:
|
|
||||||
|
|
||||||
``` yaml
|
|
||||||
input_path: "/path/to/dir"
|
|
||||||
output_path: "/path/to/out/dir"
|
|
||||||
in_stream_path: "/path/to/in/stream"
|
|
||||||
|
|
||||||
tested_executables:
|
|
||||||
- name: "team1"
|
|
||||||
executable: "/path/to/exec"
|
|
||||||
- name: "team2"
|
|
||||||
executable: "/path/to/exec2"
|
|
||||||
|
|
||||||
runtimes:
|
|
||||||
- name: "team1"
|
|
||||||
executable: "/path/to/exec"
|
|
||||||
- name: "team1"
|
|
||||||
executable: "/path/to/exec"
|
|
||||||
|
|
||||||
toolchains:
|
|
||||||
- name: "toolchain1"
|
|
||||||
steps:
|
|
||||||
- name: "step1"
|
|
||||||
executable_path: "$EXE"
|
|
||||||
arguments:
|
|
||||||
- $INPUT
|
|
||||||
- $OUTPUT
|
|
||||||
output: "out.test"
|
|
||||||
- name: "step2"
|
|
||||||
executable_path: "/bin/bash"
|
|
||||||
arguments:
|
|
||||||
- echo "Hello World"
|
|
||||||
output: "-"
|
|
||||||
- name: "toolchain2"
|
|
||||||
steps:
|
|
||||||
- name: "step1"
|
|
||||||
executable_path: "/bin/bash"
|
|
||||||
arguments:
|
|
||||||
- echo "Hello toolchain 2!"
|
|
||||||
output: "-"
|
|
||||||
```
|
|
||||||
|
|
||||||
You can refer to the [original tester](https://github.com/cmput415/Tester) documentation to see some more options (#TODO will be pasting that here)
|
|
|
@ -1,7 +1,5 @@
|
||||||
use std::path::Path;
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use crate::util;
|
pub fn grade(verbosity: u8, config_file: PathBuf, grade_config: Option<&Path>) {
|
||||||
|
|
||||||
pub fn grade(verbosity: u8, config: util::config::Config, grade_config: Option<&Path>) {
|
|
||||||
println!("Grading!");
|
println!("Grading!");
|
||||||
}
|
}
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -5,7 +5,6 @@ use clap::{Parser, Subcommand};
|
||||||
mod validate;
|
mod validate;
|
||||||
mod run;
|
mod run;
|
||||||
mod grade;
|
mod grade;
|
||||||
pub mod util;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// get cli args
|
// get cli args
|
||||||
|
@ -13,15 +12,11 @@ fn main() {
|
||||||
|
|
||||||
// parse the verbosity and eliminate the Option<>
|
// parse the verbosity and eliminate the Option<>
|
||||||
let verbosity = get_verbosity(cli.verbosity);
|
let verbosity = get_verbosity(cli.verbosity);
|
||||||
let config = util::config::parse_config(cli.config_file);
|
|
||||||
|
|
||||||
//parse the config file
|
|
||||||
// let config = parse_config(cli.config_file);
|
|
||||||
|
|
||||||
match &cli.command {
|
match &cli.command {
|
||||||
Command::Validate => validate::validate(verbosity, config),
|
Command::Validate => validate::validate(verbosity, cli.config_file),
|
||||||
Command::Run => run::run(verbosity, config),
|
Command::Run => run::run(verbosity, cli.config_file),
|
||||||
Command::Grade => grade::grade(verbosity, config, cli.grading_conf.as_deref()),
|
Command::Grade => grade::grade(verbosity, cli.config_file, cli.grading_conf.as_deref()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +28,6 @@ struct Cli {
|
||||||
#[arg(short, long, action = clap::ArgAction::Count)]
|
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||||
verbosity: Option<u8>,
|
verbosity: Option<u8>,
|
||||||
|
|
||||||
//TODO implement a thread count variable for the runner
|
|
||||||
|
|
||||||
/// Set the config file
|
/// Set the config file
|
||||||
#[arg(short, long, value_name = "CONFIG")]
|
#[arg(short, long, value_name = "CONFIG")]
|
||||||
config_file: PathBuf,
|
config_file: PathBuf,
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
use crate::util;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub fn run(verbosity: u8, config: util::config::Config) {
|
pub fn run(verbosity: u8, config_file: PathBuf) {
|
||||||
println!("Running!");
|
println!("Running!");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
pub mod config;
|
|
|
@ -1,84 +0,0 @@
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
use serde::Deserialize;
|
|
||||||
use serde_yaml::{self};
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct Config {
|
|
||||||
tested_executables: Vec<Team>,
|
|
||||||
|
|
||||||
input_path: PathBuf,
|
|
||||||
output_path: PathBuf,
|
|
||||||
in_stream_path: PathBuf,
|
|
||||||
|
|
||||||
runtimes: Option<Vec<Team>>,
|
|
||||||
|
|
||||||
toolchains: Vec<Toolchain>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct Team {
|
|
||||||
name: String,
|
|
||||||
executable: PathBuf,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct Toolchain {
|
|
||||||
name: String,
|
|
||||||
steps: Vec<Step>,}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct Step {
|
|
||||||
name: String,
|
|
||||||
|
|
||||||
executable_path: Option<PathBuf>, // if None then we use the current executable path
|
|
||||||
arguments: Vec<String>, // special string $INPUT corresponds to previous step output
|
|
||||||
output: String, // the output file name
|
|
||||||
|
|
||||||
uses_runtime: Option<bool>,
|
|
||||||
uses_in_stream: Option<bool>,
|
|
||||||
allow_error: Option<bool>
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parse_config(path: PathBuf) -> Config {
|
|
||||||
// load the yaml from the system path, if it fails, tell the user and exit
|
|
||||||
let yaml_load = std::fs::File::open(path);
|
|
||||||
let yaml_file = match yaml_load {
|
|
||||||
Ok(file) => file,
|
|
||||||
Err(error) => panic!("Failed to load configuration file 🤮, error thrown: {:?}", error),
|
|
||||||
};
|
|
||||||
|
|
||||||
let config: Config = match serde_yaml::from_reader(yaml_file) {
|
|
||||||
Ok(conf) => conf,
|
|
||||||
Err(error) => panic!("Failed to parse YAML file 😕, error: {}", error),
|
|
||||||
};
|
|
||||||
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[should_panic]
|
|
||||||
fn test_nonexistant_config() {
|
|
||||||
let path: PathBuf = PathBuf::from("src/util/test/parse_config/non_existant.yaml");
|
|
||||||
parse_config(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_load_config() {
|
|
||||||
let path: PathBuf = PathBuf::from("src/util/test/parse_config/config.yaml");
|
|
||||||
let config = parse_config(path);
|
|
||||||
println!("{:?}", config);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[should_panic]
|
|
||||||
fn test_load_bad_config() {
|
|
||||||
let path: PathBuf = PathBuf::from("src/util/test/parse_config/bad_config.yaml");
|
|
||||||
let config = parse_config(path);
|
|
||||||
println!("{:?}", config);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
|
|
||||||
input_path: "/path/to/dir"
|
|
||||||
in_stream_path: "/path/to/in/stream"
|
|
||||||
|
|
||||||
tested_executables:
|
|
||||||
- name: "team1"
|
|
||||||
executable: "/path/to/exec"
|
|
||||||
- name: "team2"
|
|
||||||
executable: "/path/to/exec2"
|
|
||||||
|
|
||||||
runtimes:
|
|
||||||
- name: "team1"
|
|
||||||
executable: "/path/to/exec"
|
|
||||||
- name: "team1"
|
|
||||||
executable: "/path/to/exec"
|
|
||||||
|
|
||||||
toolchains:
|
|
||||||
- name: "toolchain1"
|
|
||||||
steps:
|
|
||||||
- name: "step1"
|
|
||||||
executable_path: "$EXE"
|
|
||||||
arguments:
|
|
||||||
- $INPUT
|
|
||||||
- $OUTPUT
|
|
||||||
output: "out.test"
|
|
||||||
- name: "step2"
|
|
||||||
executable_path: "/bin/bash"
|
|
||||||
arguments:
|
|
||||||
- echo "Hello World"
|
|
||||||
output: "-"
|
|
||||||
- name: "toolchain2"
|
|
||||||
steps:
|
|
||||||
- name: "step1"
|
|
||||||
executable_path: "/bin/bash"
|
|
||||||
arguments:
|
|
||||||
- echo "Hello toolchain 2!"
|
|
||||||
output: "-"
|
|
|
@ -1,37 +0,0 @@
|
||||||
input_path: "/path/to/dir"
|
|
||||||
output_path: "/path/to/out/dir"
|
|
||||||
in_stream_path: "/path/to/in/stream"
|
|
||||||
|
|
||||||
tested_executables:
|
|
||||||
- name: "team1"
|
|
||||||
executable: "/path/to/exec"
|
|
||||||
- name: "team2"
|
|
||||||
executable: "/path/to/exec2"
|
|
||||||
|
|
||||||
runtimes:
|
|
||||||
- name: "team1"
|
|
||||||
executable: "/path/to/exec"
|
|
||||||
- name: "team1"
|
|
||||||
executable: "/path/to/exec"
|
|
||||||
|
|
||||||
toolchains:
|
|
||||||
- name: "toolchain1"
|
|
||||||
steps:
|
|
||||||
- name: "step1"
|
|
||||||
executable_path: "$EXE"
|
|
||||||
arguments:
|
|
||||||
- $INPUT
|
|
||||||
- $OUTPUT
|
|
||||||
output: "out.test"
|
|
||||||
- name: "step2"
|
|
||||||
executable_path: "/bin/bash"
|
|
||||||
arguments:
|
|
||||||
- echo "Hello World"
|
|
||||||
output: "-"
|
|
||||||
- name: "toolchain2"
|
|
||||||
steps:
|
|
||||||
- name: "step1"
|
|
||||||
executable_path: "/bin/bash"
|
|
||||||
arguments:
|
|
||||||
- echo "Hello toolchain 2!"
|
|
||||||
output: "-"
|
|
|
@ -1,11 +1,5 @@
|
||||||
use crate::util;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub fn validate(verbosity: u8, config: util::config::Config) {
|
pub fn validate(verbosity: u8, config_file: PathBuf) {
|
||||||
println!("Validating");
|
println!("Validating");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue