1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // Multi-Phasic Applications: SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.plugin
.util
;
12 import cc
.squirreljme
.plugin
.multivm
.VMTestFrameworkTestClassProcessor
;
13 import java
.util
.concurrent
.atomic
.AtomicReference
;
14 import org
.gradle
.api
.internal
.tasks
.testing
.DefaultTestOutputEvent
;
15 import org
.gradle
.api
.internal
.tasks
.testing
.TestResultProcessor
;
16 import org
.gradle
.api
.tasks
.testing
.TestOutputEvent
;
19 * Pushes lines to result output.
23 public class TestResultOutputStream
24 extends LinePushOutputStream
26 /** Line ending character. */
27 public static final String LINE_ENDING
=
28 System
.getProperty("line.separator");
30 /** The destination output. */
31 protected final TestOutputEvent
.Destination destination
;
34 protected final Object id
;
36 /** The processor for test results. */
37 protected final AtomicReference
<TestResultProcessor
> processor
;
40 * Initializes the output stream for test result output.
42 * @param __processor The processor for test results.
43 * @param __id The test ID.
44 * @param __destination The processor for test results.
45 * @throws NullPointerException On null arguments.
48 public TestResultOutputStream(
49 AtomicReference
<TestResultProcessor
> __processor
, Object __id
,
50 TestOutputEvent
.Destination __destination
)
51 throws NullPointerException
53 if (__processor
== null || __id
== null || __destination
== null)
54 throw new NullPointerException("NARG");
56 this.processor
= __processor
;
58 this.destination
= __destination
;
66 protected void push(String __string
)
69 TestOutputEvent
.Destination destination
= this.destination
;
71 // Output string and the line ending
72 VMTestFrameworkTestClassProcessor
.resultAction(this.processor
,
73 (__rp
) -> __rp
.output(id
, new DefaultTestOutputEvent(destination
,
74 __string
+ TestResultOutputStream
.LINE_ENDING
)));