Commit c1c44ecb authored by Michael Aaron Murphy's avatar Michael Aaron Murphy
Browse files

Initial Library/Binary Separation

The binary logic is still contained and now exposed within the library.
Yet now the binary will simply re-use the shell that was built from the library.
Therefore, there will no longer be double compiles and excessive error messages.
parent bc49acb6
......@@ -41,6 +41,9 @@ smallvec = "0.4"
unicode-segmentation = "1.2"
xdg = { git = "https://github.com/whitequark/rust-xdg" }
[lib]
path = "src/lib/lib.rs"
[profile.release]
lto = true
panic = "abort"
......
......@@ -8,6 +8,8 @@ use std::os::unix::fs::PermissionsExt;
use shell::Shell;
#[cfg(test)]
use shell::flow_control::{Function, Statement};
#[cfg(test)]
use shell;
pub(crate) fn exists(args: &[&str], shell: &Shell) -> Result<bool, String> {
let arguments = &args[1..];
......@@ -147,7 +149,7 @@ fn function_is_defined(function: &str, shell: &Shell) -> bool {
#[test]
fn test_evaluate_arguments() {
use parser::assignments::{KeyBuf, Primitive};
let mut shell = Shell::new();
let mut shell = shell::ShellBuilder::new().as_library();
// assert_eq!(evaluate_arguments(&[], &mut sink, &shell), Ok(false));
// no parameters
......@@ -268,7 +270,7 @@ fn test_evaluate_arguments() {
#[test]
fn test_match_flag_argument() {
let shell = Shell::new();
let shell = shell::ShellBuilder::new().as_library();
// we don't really care about the passed values, as long as both sited return
// the same value
......@@ -299,7 +301,7 @@ fn test_match_flag_argument() {
#[test]
fn test_match_option_argument() {
let shell = Shell::new();
let shell = shell::ShellBuilder::new().as_library();
// we don't really care about the passed values, as long as both sited return
// the same value
......@@ -326,7 +328,7 @@ fn test_path_is_directory() {
#[test]
fn test_binary_is_in_path() {
let mut shell = Shell::new();
let mut shell = shell::ShellBuilder::new().as_library();
// TODO: We should probably also test with more complex PATH-variables:
// TODO: multiple/:directories/
......@@ -357,7 +359,7 @@ fn test_string_is_nonzero() {
#[test]
fn test_array_var_is_not_empty() {
let mut shell = Shell::new();
let mut shell = shell::ShellBuilder::new().as_library();
shell
.variables
......@@ -383,7 +385,7 @@ fn test_array_var_is_not_empty() {
#[test]
fn test_string_var_is_not_empty() {
let mut shell = Shell::new();
let mut shell = shell::ShellBuilder::new().as_library();
shell.set_var("EMPTY", "");
assert_eq!(string_var_is_not_empty("EMPTY", &shell), false);
......@@ -407,7 +409,7 @@ fn test_string_var_is_not_empty() {
#[test]
fn test_function_is_defined() {
use parser::assignments::{KeyBuf, Primitive};
let mut shell = Shell::new();
let mut shell = shell::ShellBuilder::new().as_library();
// create a simple dummy function
let name_str = "test_function";
......
......@@ -45,7 +45,8 @@ fn get_var_string(name: &str, shell: &mut Shell) -> String {
#[test]
fn test_is() {
let mut shell = Shell::new();
use shell::ShellBuilder;
let mut shell = ShellBuilder::new().as_library();
shell.set_var("x", "value");
shell.set_var("y", "0");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment