Skip to content

Commit

Permalink
Merge pull request #20 from depaul-dice/feature-checkout
Browse files Browse the repository at this point in the history
Checkout Feature for Sciunit Executions
  • Loading branch information
sranasir committed Jun 19, 2023
2 parents 8b5e118 + 9e32194 commit 4c8011d
Show file tree
Hide file tree
Showing 5 changed files with 272 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

199 changes: 199 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion sciunit2/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from sciunit2.command.sort import SortCommand
from sciunit2.command.push import PushCommand
from sciunit2.command.copy import CopyCommand
from sciunit2.command.checkout import CheckoutCommand
from sciunit2.command.post_install import PostInstallCommand
from sciunit2.command.diff import DiffCommand
from sciunit2.command.export import ExportCommand
Expand All @@ -29,7 +30,7 @@
__cmds__ = [CreateCommand, OpenCommand, ExecCommand, RepeatCommand,
ListCommand, ShowCommand, GivenCommand, CommitCommand, RmCommand,
SortCommand, PushCommand, CopyCommand, PostInstallCommand,
DiffCommand, RemoveCommand, ExportCommand]
DiffCommand, RemoveCommand, ExportCommand, CheckoutCommand]


def short_usage(out):
Expand Down
29 changes: 29 additions & 0 deletions sciunit2/command/checkout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from __future__ import absolute_import

from sciunit2.command import AbstractCommand
from sciunit2.command.context import CheckoutContext
from sciunit2.exceptions import CommandLineError
from sciunit2.util import quoted_format
import sciunit2.core

from getopt import getopt
import sys


class CheckoutCommand(AbstractCommand):
name = 'checkout'

@property
def usage(self):
return [('checkout <execution id>',
"Checkout the execution of <execution id>")]

def run(self, args):
optlist, args = getopt(args, '')
if len(args) != 1:
raise CommandLineError
with CheckoutContext(args[0]) as (pkgdir, _):
return pkgdir

def note(self, project_dir):
return quoted_format('Checked out at: {0}\n', project_dir)
36 changes: 36 additions & 0 deletions tests/test_checkout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from __future__ import absolute_import

from nose.tools import *
import os
import testpath

from tests import testit


class TestCheckout(testit.LocalCase):
def test_all(self):
with assert_raises(SystemExit) as r:
testit.sciunit('checkout')
assert_equal(r.exception.code, 2)

with assert_raises(SystemExit) as r:
testit.sciunit('checkout', '-i')
assert_equal(r.exception.code, 2)

with assert_raises(SystemExit) as r:
testit.sciunit('checkout', 'e1')
assert_equal(r.exception.code, 1)

testit.sciunit('create', 'ok')

with assert_raises(SystemExit) as r:
testit.sciunit('checkout', 'asdf')
assert_equal(r.exception.code, 1)

with assert_raises(SystemExit) as r:
testit.sciunit('checkout', 'e1')
assert_equal(r.exception.code, 1)

testit.sciunit('exec', 'pwd')
testit.sciunit('checkout', 'e1')
assert_true(os.path.isdir('tmp/ok/cde-package'))

0 comments on commit 4c8011d

Please sign in to comment.