File: process-test-result.rb

package info (click to toggle)
ruby-test-unit 3.7.7-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,348 kB
  • sloc: ruby: 16,403; makefile: 9
file content (55 lines) | stat: -rw-r--r-- 1,088 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#--
#
# Author:: Tsutomu Katsube.
# Copyright:: Copyright (c) 2025 Tsutomu Katsube. All rights reserved.
# License:: Ruby license.

module Test
  module Unit
    class ProcessTestResult
      def initialize(output)
        @output = output
      end

      def add_run
        send_result(__method__)
      end

      def add_pass
        send_result(__method__)
      end

      # Records an individual assertion.
      def add_assertion
        send_result(__method__)
      end

      def add_error(error)
        send_result(__method__, error)
      end

      def add_failure(failure)
        send_result(__method__, failure)
      end

      def add_pending(pending)
        send_result(__method__, pending)
      end

      def add_omission(omission)
        send_result(__method__, omission)
      end

      def add_notification(notification)
        send_result(__method__, notification)
      end

      private

      def send_result(action, *args)
        Marshal.dump({status: :result, action: action, args: args}, @output)
        @output.flush
      end
    end
  end
end