Skip to content

Commit

Permalink
Merge pull request #8 from craftytrickster/multi-thread-fix
Browse files Browse the repository at this point in the history
Multi thread fix
  • Loading branch information
craftytrickster authored Aug 31, 2017
2 parents 7e2a90a + 8336338 commit 8fb7244
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
8 changes: 3 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
[package]
name = "mock_me"
version = "0.2.2"
version = "0.2.3"
authors = ["David Raifaizen <[email protected]>"]
description = "MockMe is a tool used to mock dependencies / function calls when running unit (lib) tests in Rust."
repository = "https://github.com/craftytrickster/mock_me"
readme = "README.md"
keywords = ["unit-test", "test", "mock", "mocking"]
categories = ["development-tools::testing"]
license = "MIT"

[dependencies]
mock_me_test_context = "0.1.1"
mock_me_test_context = "0.1.2"

[lib]
crate-type = ["proc-macro"]
crate-type = ["proc-macro"]
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ MockMe

MockMe is a tool used to mock dependencies / function calls when running unit (lib) tests in Rust.

## Caution

Unfortunately, due to the non determinstic order of how tests are performed by rust/cargo,
a mocked function can only be injected by a single test. If it is mocked by multiple tests,
it may be subject to random panics due to race conditions.
As a result, this is mainly just an experimental toy crate and it should not be used in
production codebases.


## How to Use

*Currently, only works on nightly.*
Expand Down Expand Up @@ -53,4 +62,4 @@ Code contributions, feature requests and bug reports are all appreciated.
## Limitations

Currently, the library is unable to infer the signature of the function that is being mocked. As a result,
the programmer needs to provide it, which hurts the ergonomics of the library.
the programmer needs to provide it, which hurts the ergonomics of the library.
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@
//! ```
#![feature(proc_macro)]
#![feature(insert_str)]
extern crate proc_macro;
use proc_macro::TokenStream;

extern crate mock_me_test_context;

use std::fmt::Write;

mod macro_helper;
Expand Down
11 changes: 0 additions & 11 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,3 @@ fn test_with_silly_func_1() {
fn replacement_1(num_1: f64, num_2: f64) -> f64 {
num_1 - num_2
}

#[test]
#[inject(fun="replacement_2")]
fn test_with_silly_func_2() {
let result = function_with_fun_id();
assert_eq!(result, 600f64);
}

fn replacement_2(num_1: f64, num_2: f64) -> f64 {
num_1 * num_2
}

0 comments on commit 8fb7244

Please sign in to comment.