-
Notifications
You must be signed in to change notification settings - Fork 4
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
12 changed files
with
412 additions
and
32 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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
bin | ||
cover | ||
docs/build | ||
dist | ||
|
||
.coverage | ||
.jig | ||
|
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,36 @@ | ||
import argparse | ||
|
||
from jig.commands.base import BaseCommand | ||
from jig.runner import Runner | ||
|
||
_parser = argparse.ArgumentParser( | ||
description='Run plugins on a revision range', | ||
usage='jig check [-h] [-p PLUGIN] [--revrange REVISION_RANGE] [PATH]') | ||
|
||
_parser.add_argument( | ||
'--plugin', '-p', | ||
help='Only run this specific named plugin') | ||
_parser.add_argument( | ||
'--rev-range', dest='rev_range', default='HEAD^1..HEAD', | ||
help='Git revision range to run the plugins against') | ||
_parser.add_argument( | ||
'path', nargs='?', default='.', | ||
help='Path to the Git repository') | ||
|
||
|
||
class Command(BaseCommand): | ||
parser = _parser | ||
|
||
def process(self, argv): | ||
path = argv.path | ||
rev_range = argv.rev_range | ||
|
||
# Make the runner use our view | ||
runner = Runner(view=self.view) | ||
|
||
runner.main( | ||
path, | ||
plugin=argv.plugin, | ||
rev_range=rev_range, | ||
interactive=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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# coding=utf-8 | ||
from unittest import SkipTest | ||
|
||
from jig.exc import ForcedExit | ||
from jig.tests.testcase import ( | ||
CommandTestCase, PluginTestCase, result_with_hint) | ||
from jig.plugins import set_jigconfig | ||
from jig.output import ATTENTION | ||
from jig.commands import report | ||
|
||
|
||
class TestReportCommand(CommandTestCase, PluginTestCase): | ||
|
||
""" | ||
Test the report command. | ||
""" | ||
command = report.Command | ||
|
||
def setUp(self): | ||
super(TestReportCommand, self).setUp() | ||
|
||
self._add_plugin(self.jigconfig, 'plugin01') | ||
set_jigconfig(self.gitrepodir, config=self.jigconfig) | ||
|
||
# Create a few commits | ||
self.commit(self.gitrepodir, 'a.txt', 'a') | ||
self.commit(self.gitrepodir, 'b.txt', 'b') | ||
self.commit(self.gitrepodir, 'c.txt', 'c') | ||
|
||
def test_cannot_resolve_revision_range(self): | ||
""" | ||
Given a range that is invalid it notifies the user. | ||
""" | ||
with self.assertRaises(ForcedExit) as ec: | ||
self.run_command('--rev-range FOO..BAR {}'.format(self.gitrepodir)) | ||
|
||
self.assertEqual(1, ec.exception.message) | ||
|
||
self.assertTrue(self.error) | ||
|
||
def test_reports_one_commit(self): | ||
""" | ||
With a range indicating one commit it reports on that one. | ||
""" | ||
with self.assertRaises(SystemExit) as ec: | ||
self.run_command('--rev-range HEAD^1..HEAD {}'.format(self.gitrepodir)) | ||
|
||
self.assertEqual(0, ec.exception.message) | ||
|
||
self.assertResults(u""" | ||
▾ plugin01 | ||
⚠ line 1: c.txt | ||
c is + | ||
{0} Jig ran 1 plugin | ||
Info 0 Warn 1 Stop 0 | ||
""".format(ATTENTION), self.output) | ||
|
||
def test_defaults_latest_commit(self): | ||
""" | ||
Without a revision range it uses HEAD^1..HEAD. | ||
""" | ||
with self.assertRaises(SystemExit) as ec: | ||
self.run_command('{}'.format(self.gitrepodir)) | ||
|
||
self.assertResults(u""" | ||
▾ plugin01 | ||
⚠ line 1: c.txt | ||
c is + | ||
{0} Jig ran 1 plugin | ||
Info 0 Warn 1 Stop 0 | ||
""".format(ATTENTION), self.output) | ||
|
||
def test_reports_two_commits(self): | ||
""" | ||
With a range indicating two commits it reports on both. | ||
""" | ||
with self.assertRaises(SystemExit) as ec: | ||
self.run_command('--rev-range HEAD~2..HEAD {}'.format(self.gitrepodir)) | ||
|
||
self.assertEqual(0, ec.exception.message) | ||
|
||
self.assertResults(u""" | ||
▾ plugin01 | ||
⚠ line 1: c.txt | ||
c is + | ||
⚠ line 1: b.txt | ||
b is + | ||
{0} Jig ran 1 plugin | ||
Info 0 Warn 2 Stop 0 | ||
""".format(ATTENTION), self.output) | ||
|
||
def test_reports_only_one_plugin(self): | ||
""" | ||
If a plugin is given it will only report on that plugin. | ||
""" | ||
with self.assertRaises(SystemExit) as ec: | ||
self.run_command('--plugin plugin01 --rev-range HEAD^1..HEAD {}'.format(self.gitrepodir)) | ||
|
||
self.assertEqual(0, ec.exception.message) | ||
|
||
self.assertResults(u""" | ||
▾ plugin01 | ||
⚠ line 1: c.txt | ||
c is + | ||
{0} Jig ran 1 plugin | ||
Info 0 Warn 1 Stop 0 | ||
""".format(ATTENTION), self.output) |
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
Oops, something went wrong.