-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
target | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import unittest | ||
import shutil | ||
import os | ||
from queue import Queue | ||
from textwrap import dedent | ||
from contextlib import ExitStack, contextmanager | ||
from shutil import which | ||
from unittest.case import skipIf | ||
|
||
from coala_utils.ContextManagers import prepare_file | ||
from coalib.settings.Section import Section | ||
|
||
from bears.rust.RustClippyLintBear import RustClippyLintBear | ||
|
||
|
||
@skipIf(which('cargo') is None, 'Cargo is not installed') | ||
class RustClippyLintBearTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.section = Section('name') | ||
self.queue = Queue() | ||
self.file_dict = {} | ||
self.uut = RustClippyLintBear(self.file_dict, self.section, self.queue) | ||
|
||
def change_directory(self, directory_name): | ||
test_path = os.path.abspath(os.path.join(os.path.dirname(__file__), | ||
directory_name)) | ||
os.chdir(test_path) | ||
|
||
def test_prerequisites(self): | ||
_shutil_which = shutil.which | ||
try: | ||
shutil.which = lambda *args, **kwargs: None | ||
self.assertEqual(RustClippyLintBear.check_prerequisites(), | ||
'cargo is not installed.') | ||
|
||
shutil.which = lambda *args, **kwargs: 'path/to/git' | ||
self.assertTrue(RustClippyLintBear.check_prerequisites()) | ||
finally: | ||
shutil.which = _shutil_which | ||
|
||
def test_ok_source(self): | ||
self.change_directory('test_ok') | ||
results = list(self.uut.run()) | ||
self.assertTrue(len(results) == 0) | ||
|
||
def test_bad_source(self): | ||
self.change_directory('test_bad') | ||
results = list(self.uut.run()) | ||
self.assertTrue(len(results) >= 2) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
name = "coala_test_files" | ||
version = "0.1.0" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
name = "coala_test_files" | ||
version = "0.1.0" | ||
|
||
[dependencies] |