Skip to content

Instantly share code, notes, and snippets.

@cfcosta
Created June 5, 2017 03:38
Show Gist options
  • Save cfcosta/ccea394a63ab97acf9b383a909193361 to your computer and use it in GitHub Desktop.
Save cfcosta/ccea394a63ab97acf9b383a909193361 to your computer and use it in GitHub Desktop.
$ cargo test
Compiling hello v0.1.0 (file:///home/cfcosta/Projects/hello)
error: internal compiler error: Error constructed but not emitted
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'explicit panic', /checkout/src/librustc_errors/diagnostic_builder.rs:204
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
at /checkout/src/libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at /checkout/src/libstd/sys_common/backtrace.rs:60
at /checkout/src/libstd/panicking.rs:355
3: std::panicking::default_hook
at /checkout/src/libstd/panicking.rs:365
4: std::panicking::rust_panic_with_hook
at /checkout/src/libstd/panicking.rs:549
5: std::panicking::begin_panic
6: <rustc_errors::diagnostic_builder::DiagnosticBuilder<'a> as core::ops::Drop>::drop
7: core::ptr::drop_in_place
at /checkout/src/libcore/ptr.rs:60
8: core::ptr::drop_in_place
at /checkout/src/libcore/ptr.rs:60
9: <core::result::Result<T, E>>::ok
at /checkout/src/libcore/result.rs:342
10: <stainless::describe::DescribeState as stainless::parse::Parse<(syntax_pos::Span, &'a mut syntax::ext::base::ExtCtxt<'b>, core::option::Option<syntax_pos::symbol::Ident>)>>::parse
at /home/cfcosta/.cargo/registry/src/github.com-1ecc6299db9ec823/stainless-0.1.11/src/parse.rs:143
11: stainless::describe::describe
at /home/cfcosta/.cargo/registry/src/github.com-1ecc6299db9ec823/stainless-0.1.11/src/describe.rs:68
12: core::ops::Fn::call
at /checkout/src/libcore/ops.rs:2588
13: <F as syntax::ext::base::IdentMacroExpander>::expand
at /checkout/src/libsyntax/ext/base.rs:260
14: syntax::ext::expand::MacroExpander::expand_bang_invoc
15: syntax::ext::expand::MacroExpander::expand
16: syntax::ext::expand::MacroExpander::expand_crate
17: rustc_driver::driver::phase_2_configure_and_expand::{{closure}}
18: rustc_driver::driver::phase_2_configure_and_expand
19: rustc_driver::driver::compile_input
20: rustc_driver::run_compiler
error: Could not compile `hello`.
To learn more, run the command again with --verbose.
[package]
name = "hello"
version = "0.1.0"
authors = ["Cainã Costa <[email protected]>"]
[dependencies]
rocket = { version = "*", features = ["testing"] }
rocket_codegen = "*"
[dev-dependencies]
stainless = "*"
#![feature(plugin)]
#![plugin(rocket_codegen)]
#![cfg_attr(test, plugin(stainless))]
extern crate rocket;
pub mod routes {
#[get("/health")]
pub fn health() -> String {
String::from("OK")
}
}
#[cfg(test)]
#[allow(unused_variables)]
mod tests {
use rocket;
use rocket::testing::MockRequest;
use rocket::http::{Status, Method};
use routes;
describe! status {
before_each {
let rocket = rocket::ignite().mount("/", routes![routes::health])
let mut request = MockRequest::new(Method::Get, "/health");
let mut response = request.dispatch_with(&rocket);
let body = res.body().and_then(|b| b.into_string()).unwrap();
}
it "responds with 200 OK" {
assert_eq!(res.status(), Status::Ok);
}
}
}
fn main() {
rocket::ignite()
.mount("/", routes![routes::health])
.launch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment