-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into encoding_inlinediff
- Loading branch information
Showing
9 changed files
with
171 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
env: | ||
global: | ||
- PACKAGE="GitSavvy" | ||
- SUBLIME_TEXT_VERSION="3" | ||
- UNITTESTING_TAG="master" | ||
|
||
matrix: | ||
include: | ||
- os: linux | ||
language: python | ||
python: 3.3 | ||
- os: osx | ||
language: generic | ||
|
||
before_install: | ||
- curl -OL https://raw.githubusercontent.com/randy3k/UnitTesting/master/sbin/travis.sh | ||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then | ||
export DISPLAY=:99.0; | ||
sh -e /etc/init.d/xvfb start; | ||
fi | ||
- git config --global user.email gitsavvy@gitsavvy.com | ||
- git config --global user.name GitSavvy | ||
|
||
install: | ||
- sh travis.sh bootstrap | ||
- sh travis.sh install_package_control | ||
|
||
script: | ||
- sh travis.sh run_tests --coverage | ||
|
||
after_success: | ||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then | ||
brew update; | ||
brew install python3; | ||
pip3 install python-coveralls; | ||
fi | ||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then | ||
pip install python-coveralls; | ||
fi | ||
- coveralls | ||
|
||
notifications: | ||
email: false |
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
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,14 @@ | ||
environment: | ||
PACKAGE: "GitSavvy" | ||
SUBLIME_TEXT_VERSION : "3" | ||
UNITTESTING_TAG : "master" | ||
|
||
install: | ||
- ps: appveyor DownloadFile "https://raw.githubusercontent.com/randy3k/UnitTesting/master/sbin/appveyor.ps1" | ||
- ps: .\appveyor.ps1 "bootstrap" -verbose | ||
- ps: .\appveyor.ps1 "install_package_control" -verbose | ||
|
||
build: off | ||
|
||
test_script: | ||
- ps: .\appveyor.ps1 "run_tests" -verbose |
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,32 @@ | ||
# Package Testing | ||
|
||
We try to cover the most crucial functionality with unit tests using | ||
[UnitTesting](https://github.com/randy3k/UnitTesting). To run the tests | ||
locally, you should install UnitTesting via Package Control. | ||
|
||
## Run the test specs locally | ||
|
||
First you need to [clone](https://github.com/divmain/GitSavvy#less-simple) GitSavvy repo from source. | ||
Open the directory `GitSavvy` and simply run the command `UnitTesting: Test Current Project` | ||
|
||
## Some details about DeferrableTestCase | ||
|
||
[DeferrableTestCase][1] is used to write the test cases. They are executed by | ||
the [DeferringTextTestRunner][2] and the runner expects not only regular test | ||
functions, but also generators. If the test function is a generator, it does | ||
the following | ||
|
||
- if the yielded object is a callable, the runner will evaluate the | ||
[callable][3] and check its returned value. If the result is `True`, the | ||
runner continues the generator, if not, the runner will wait until the | ||
condition is met. | ||
|
||
- If the yielded object is an integer, say `x`, then it will [continue][4] the | ||
generator after `x` ms. | ||
|
||
- Otherwise, the `yield` statement will always wait for 10 ms. | ||
|
||
[1]: https://github.com/randy3k/UnitTesting/blob/dc810ee334bb031710b859478faaf50293880995/unittesting/core/st3/runner.py#L49 | ||
[2]: https://github.com/randy3k/UnitTesting/blob/dc810ee334bb031710b859478faaf50293880995/unittesting/core/st3/runner.py#L7 | ||
[3]: https://github.com/randy3k/UnitTesting/blob/dc810ee334bb031710b859478faaf50293880995/unittesting/core/st3/runner.py#L49 | ||
[4]: https://github.com/randy3k/UnitTesting/blob/dc810ee334bb031710b859478faaf50293880995/unittesting/core/st3/runner.py#L57 |
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,49 @@ | ||
import sublime | ||
import subprocess | ||
import os | ||
from unittesting.helpers import TempDirectoryTestCase | ||
|
||
|
||
def tidy_path(path): | ||
return os.path.realpath(os.path.normcase(path)) | ||
|
||
|
||
class AssertionsMixin: | ||
|
||
def assert_git_status(self, status): | ||
""" | ||
Assertion of the current git status. `status` should be a list of 4 intergers: | ||
The lengths of the staged, unstaged, untracked and conflicted entries. | ||
""" | ||
self.assertEqual( | ||
[len(x) for x in self.sort_status_entries(self.get_status())], | ||
status) | ||
|
||
|
||
class GitRepoTestCase(TempDirectoryTestCase, AssertionsMixin): | ||
""" | ||
TempDirectoryTestCase is a subclass of DeferrableTestCase which creates and opens a temp | ||
directory before running the test case and close the window when the test case finishes running. | ||
https://github.com/randy3k/UnitTesting/blob/master/unittesting/helpers.py | ||
""" | ||
# add readme file as the initial commit | ||
initialize = True | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
# since TempDirectoryTestCase.setUpClass is a generator | ||
yield from super(GitRepoTestCase, cls).setUpClass() | ||
assert tidy_path(cls._temp_dir) == tidy_path(sublime.active_window().folders()[0]) | ||
assert tidy_path(cls._temp_dir) == tidy_path(cls.window.folders()[0]) | ||
subprocess.check_call(["git", "init"], cwd=cls._temp_dir) | ||
if cls.initialize: | ||
cls.add_readme() | ||
|
||
@classmethod | ||
def add_readme(cls): | ||
readme = os.path.join(cls._temp_dir, "README.md") | ||
f = open(readme, "w") | ||
f.write("README") | ||
f.close() | ||
subprocess.check_call(["git", "add", "README.md"], cwd=cls._temp_dir) | ||
subprocess.check_call(["git", "commit", "-m", "Add README.md"], cwd=cls._temp_dir) |
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,21 @@ | ||
import os | ||
from .common import GitRepoTestCase | ||
from GitSavvy.core import git_command | ||
|
||
|
||
class TestInitialization(GitRepoTestCase, git_command.GitCommand): | ||
|
||
def test_is_master(self): | ||
branch = self.get_current_branch_name() | ||
self.assertEqual(branch, "master") | ||
|
||
|
||
class TestStageFile(GitRepoTestCase, git_command.GitCommand): | ||
|
||
def test_stage_file(self): | ||
foo = os.path.join(self.repo_path, "foo") | ||
with open(foo, "w") as f: | ||
f.write("foo") | ||
self.assert_git_status([0, 0, 1, 0]) | ||
self.stage_file(foo) | ||
self.assert_git_status([1, 0, 0, 0]) |
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,4 @@ | ||
{ | ||
"deferred": true, | ||
"capture_console": true | ||
} |