Skip to content

Commit

Permalink
Add tests for flycheck-rust-crate-root [#417]
Browse files Browse the repository at this point in the history
Based on code shown in #386
  • Loading branch information
swsnr committed Jun 26, 2014
1 parent b0a9ee2 commit 939c3ec
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/flycheck-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -4499,6 +4499,23 @@ Why not:
;; TODO: How can we test this without adding binary libraries to our repo?
(error "Not implemented!"))

(ert-deftest flycheck-define-checker/rust-crate-root-not-set ()
:tags '(builtin-checker external-tool language-rust)
(skip-unless (flycheck-check-executable 'rust))
(flycheck-test-should-syntax-check
"checkers/rust_crate/foo.rs" 'rust-mode
'(1 5 error "unresolved import `super::bar`" :checker rust)))

(ert-deftest flycheck-define-checker/rust-crate-root ()
:tags '(builtin-checker external-tool language-rust)
(skip-unless (flycheck-check-executable 'rust))
(let ((flycheck-rust-crate-root (flycheck-test-resource-filename
"checkers/rust_crate/main.rs")))
(flycheck-test-should-syntax-check
"checkers/rust_crate/foo.rs" 'rust-mode
'(3 9 warning "unused variable: `x`, #[warn(unused_variable)] on by default"
:checker rust))))

(ert-deftest flycheck-define-checker/sass ()
:tags '(builtin-checker external-tool language-sass)
(skip-unless (flycheck-check-executable 'sass))
Expand Down
1 change: 1 addition & 0 deletions test/resources/checkers/rust_crate/bar.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub static BAR: int = 42;
5 changes: 5 additions & 0 deletions test/resources/checkers/rust_crate/foo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use super::bar;
pub fn foo() {
let x = "10";
println!("hey {}", bar::BAR);
}
10 changes: 10 additions & 0 deletions test/resources/checkers/rust_crate/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![crate_type="bin"]
#![crate_id="flycheck"]

mod bar;
mod foo;

pub fn main() {
foo::foo();
println!("Hello, world!");
}

0 comments on commit 939c3ec

Please sign in to comment.