[PATCH] Add a TEST-OP-TEST-FAILURE condition for test libraries to sub-class

Anton Vodonosov avodonosov at yandex.ru
Mon Sep 30 11:23:02 UTC 2019


Hi.

Thank you, everyone, for addressing this topic, having a unified representation
of test results would be very useful.

A couple of thoughts:


- success should also be signaled, so we can distinguish a version where
  this new protocol is not implemented from the version where tests pass
- the minimal requirement is a success / failure designator, the failed
  test names can be optional
- For a caller of asdf:test-op it would be more convenient to have a single
  signal. Ideally, it should be just a return value of the asdf:operate function,
  as I understand we only consider the possibility of test result being signaled
  multiple times during test-op because we hope to make it work for everyone
  without library authors explicitly modify their code, but adding this new
  functionality to test frameworks. A good goal, although I can imaging
  some corner cases. Still, even if we expect test results being signalled
  multiple times during a test-op, it would be good to provide a wrapper
  which aggregates them into a single return value.
     
        (common-test-results:collect (asdf:test-system "my-system"))

- as others mention, to me it also occurred this new functionality
  should not necessarily be declared inside of ASDF, it could be
  some separate library, say common-test-result. I'm not 100% sure
  about this, but currently, lean more towards separate lib, at least
  for the beginning. ASDF test-op docs could just referer to it.
- If delivering test results thourhg a condition, test failure should not 
  be an error or warning, in my opinion. Test error is an anticipated
  possible outcome. An error during tests an abnormal situation - 
  no access to needed files, memory exhausted, null pointers, etc.
- slot for the failing asdf system could probably be avoided, 
  the list failed test names could be enough, if the names are "fully qualified"
  i.e. include package or system name.



27.09.2019, 10:20, "Vladimir Sedach" <vas at oneofus.la>:
> Thank you for the specific suggestions Mark.
>
> Mark Evenson <evenson at panix.com> writes:
>
>>  1. Have a slot in your base condition class TEST-OP-TEST-FAILURE in
>>  which one can record the ASDF component which caused the failure.
>>  It is probably possible to dig this information out of the stack,
>>  but that will be messy. This would also allow for distinguishing
>>  when multiple TEST-OP-TEST-FAILURES are signaled from a single
>>  ASDF:TEST-OP invocation, as will be the case when one “chains” test
>>  invocation over many ASDF systems.
>
> This is really easy to do with a special variable in an initarg, but
> are there any systems that you know of that do this? I would
> definitely like to test with them, because I thought that nested
> TEST-OP was not supposed to work. From the "More Elaborate Testing"
> section of the best practices document¹:
>
> "You MUST NOT call asdf:operate or any of its derivatives, such as
> asdf:load-system or asdf:test-system from within a perform method."
>
> Unfortunately it looks like that is what ROVE:RUN-SYSTEM-TESTS does
> exactly that.
>
>>  2. Provide an implementation of the subclass of
>>  TEST-OP-TEST-FAILURE that contains the basic structure of a
>>  reporter class for the information that should be present in all
>>  test frameworks, namely the total number of tests run, the number
>>  of failed tests, the identities of the failed tests, and a slot for
>>  a human readable error message, along with a reporter function that
>>  displays this information. Having an implementation class to work
>>  from would make it easier for test frameworks to adapt.
>
> I tried to avoid enforcing required slots, but as both
> asdf-test-harness and cl-test-grid want a list of failed tests, that
> is a strong case to make the above slots required in
> TEST-OP-TEST-FAILURE itself.
>
> cl-test-grid wants a list of test names as strings (it wants them
> down-cased, but that is a detail that can be left to cl-test-grid). A
> list of strings is a requirement that any test library should be able
> to satisfy (worst case, it could be a list of random names), and
> looks to me specific enough for most test harness use cases.
>
> The length of the list of failed test names gives the count of failed
> tests.
>
> It seems to me like having a slot for an error message is redundant
> with the reporter function, given that I think it should be up to the
> test library to define the reporter function, and not for
> TEST-OP-TEST-FAILURES to dictate how it is printed. That way, if a
> test library has a flag to print results in machine readable format,
> the flag will work without any changes if the overridden reporter
> function re-uses the library's output facilities, and as long as the
> test harness PRINCs the condition, the test harness does not need to
> do anything either.
>
>>  3. Go ahead and define the subclass of this condition when no tests
>>  have been run.
>
> I thought about doing this, but with the above slots, there is no
> need to - the test library can signal TEST-OP-TEST-FAILURE with a 0
> count of total number of tests run.
>
>>  4. As for adoption by test framework your strategy, we will have
>>  the problem that a given test framework won’t want to adopt the
>>  conditions because it isn’t in the version of ASDF they are using,
>>  or can easily get a hold of. To solve this, we might somehow define
>>  the code within the ASDF source tree so that one can make a
>>  standalone ASDF system (“ASDF-TEST-CONDITIONS” or some such) that
>>  one may include separately from actually upgrading ASDF.
>
> That is something that Robert brought up on the merge request
> discussion.² It looks like this can be handled with the #+ #- feature
> macros or #. read macro to provide CL:WARNING as a fallback
> super-class. I am open to any ideas.
>
> I went ahead and added the slots to ASDF², the FiveAM³, and the rove⁴
> implementations. Up next, I am going to work on adding support to
> cl-test-grid for a library that uses rove, which cl-test-grid does
> not support yet.
>
> ¹ https://github.com/fare/asdf/blob/master/doc/best_practices.md
> ² https://gitlab.common-lisp.net/asdf/asdf/merge_requests/124
> ³ https://github.com/sionescu/fiveam/pull/58
>https://github.com/fukamachi/rove/pull/29
>
> --
> Vladimir Sedach
> Software engineering services in Los Angeles https://oneofus.la



More information about the asdf-devel mailing list