[Piglit] [PATCH 3/4] log: Rename get_current and mark_complete

Ilia Mirkin imirkin at alum.mit.edu
Mon Feb 17 13:19:39 PST 2014


On Mon, Feb 17, 2014 at 2:45 PM, Dylan Baker <baker.dylan.c at gmail.com> wrote:
> This replaces very specific names with more general ones. This should be
> more useful if we wanted to subclass log at some point.
>
> Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>

Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>

> ---
>  framework/core.py            |  4 ++--
>  framework/log.py             |  4 ++--
>  framework/tests/log_tests.py | 48 ++++++++++++++++++++++----------------------
>  3 files changed, 28 insertions(+), 28 deletions(-)
>
> diff --git a/framework/core.py b/framework/core.py
> index f6ae80f..13ed235 100644
> --- a/framework/core.py
> +++ b/framework/core.py
> @@ -434,7 +434,7 @@ class Test(object):
>              ``spec/glsl-1.30/preprocessor/compiler/keywords/void.frag``.
>          '''
>
> -        log_current = log.get_current()
> +        log_current = log.pre_log()
>          # Run the test
>          if env.execute:
>              try:
> @@ -472,7 +472,7 @@ class Test(object):
>          else:
>              test_result = 'dry-run'
>              log.log()
> -        log.mark_complete(log_current, test_result)
> +        log.post_log(log_current, test_result)
>
>
>  class Group(dict):
> diff --git a/framework/log.py b/framework/log.py
> index 7cdc940..676d122 100644
> --- a/framework/log.py
> +++ b/framework/log.py
> @@ -55,7 +55,7 @@ class Log(object):
>                                    str(self.__total).zfill(self.__pad))
>
>      @synchronized_self
> -    def mark_complete(self, value, result):
> +    def post_log(self, value, result):
>          """ Used to mark a test as complete in the log
>
>          Arguments:
> @@ -89,7 +89,7 @@ class Log(object):
>          sys.stdout.flush()
>
>      @synchronized_self
> -    def get_current(self):
> +    def pre_log(self):
>          """ Returns a new number to know what processes are running """
>          x = self.__generator.next()
>          self.__running.append(x)
> diff --git a/framework/tests/log_tests.py b/framework/tests/log_tests.py
> index 09d99e4..8b817f2 100644
> --- a/framework/tests/log_tests.py
> +++ b/framework/tests/log_tests.py
> @@ -35,60 +35,60 @@ def test_initialize_log():
>      assert log
>
>
> -def test_get_current_return():
> +def test_pre_log_return():
>      """ Test that pre_log returns a number """
>      log = Log(100)
>
> -    ret = log.get_current()
> +    ret = log.pre_log()
>      nt.assert_true(isinstance(ret, (IntType, FloatType, LongType)),
> -                   msg="Log.get_current() didn't return a numeric type!")
> +                   msg="Log.pre_log() didn't return a numeric type!")
>
>
> -def test_mark_complete_increment_complete():
> -    """ Tests that Log.mark_complete() increments self.__complete """
> +def test_post_log_increment_complete():
> +    """ Tests that Log.post_log() increments self.__complete """
>      log = Log(100)
> -    ret = log.get_current()
> -    log.mark_complete(ret, 'pass')
> +    ret = log.pre_log()
> +    log.post_log(ret, 'pass')
>      nt.assert_equal(log._Log__complete, 1,
> -                    msg="Log.mark_complete() did not properly incremented "
> +                    msg="Log.post_log() did not properly incremented "
>                          "Log.__current")
>
>
> -def check_mark_complete_increment_summary(stat):
> -    """ Test that passing a result to mark_complete works correctly """
> +def check_post_log_increment_summary(stat):
> +    """ Test that passing a result to post_log works correctly """
>      log = Log(100)
> -    ret = log.get_current()
> -    log.mark_complete(ret, stat)
> +    ret = log.pre_log()
> +    log.post_log(ret, stat)
>      print log._Log__summary
>      nt.assert_equal(log._Log__summary[stat], 1,
>                      msg="Log.__summary[{}] was not properly "
>                          "incremented".format(stat))
>
>
> -def test_mark_complete_increment_summary():
> +def test_post_log_increment_summary():
>      """ Generator that creates tests for self.__summary """
> -    yieldable = check_mark_complete_increment_summary
> +    yieldable = check_post_log_increment_summary
>
>      for stat in valid_statuses:
> -        yieldable.description = ("Test that Log.mark_complete increments "
> +        yieldable.description = ("Test that Log.post_log increments "
>                                   "self._summary[{}]".format(stat))
>          yield yieldable, stat
>
>
> -def test_mark_complete_removes_complete():
> -    """ Test that Log.mark_complete() removes finished tests from __running """
> +def test_post_log_removes_complete():
> +    """ Test that Log.post_log() removes finished tests from __running """
>      log = Log(100)
> -    ret = log.get_current()
> -    log.mark_complete(ret, 'pass')
> +    ret = log.pre_log()
> +    log.post_log(ret, 'pass')
>      nt.assert_not_in(ret, log._Log__running,
>                       msg="Running tests not removed from running list")
>
>
>  @nt.raises(AssertionError)
> -def check_mark_complete_incrment_summary_bad():
> +def check_post_log_incrment_summary_bad():
>      log = Log(100)
> -    ret = log.get_current()
> -    log.mark_complete(ret, 'fails')
> +    ret = log.pre_log()
> +    log.post_log(ret, 'fails')
>
>
>  def check_output(stat):
> @@ -96,8 +96,8 @@ def check_output(stat):
>      log = Log(100)
>
>      for x in stat:
> -        ret = log.get_current()
> -        log.mark_complete(ret, x)
> +        ret = log.pre_log()
> +        log.post_log(ret, x)
>
>      # Print to stdout, and then capture it, the capture absolutely needs to
>      # imediatly after log.log()
> --
> 1.8.5.5
>


More information about the Piglit mailing list