-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add DotWritingProgressMonitor Test * Rename git-check as "onchange" * Fix RunCommandOnExamplesTest to actually run commands on examples * Make RunCommandOnExamplesTest print out what its skipping * Attempt to fix SLF4J warnings Signed-off-by: reidspencer <reid.spencer@yoppworks.com>
- Loading branch information
1 parent
86e47a0
commit 3738879
Showing
12 changed files
with
279 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
git-check/src/test/scala/com/reactific/riddl/translator/git/GitCheckTranslatorTest.scala
This file was deleted.
Oops, something went wrong.
File renamed without changes.
40 changes: 40 additions & 0 deletions
40
...ge/src/main/scala/com/reactific/riddl/translator/onchange/DotWritingProgressMonitor.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2019 Ossum, Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.reactific.riddl.translator.onchange | ||
|
||
import com.reactific.riddl.language.CommonOptions | ||
import com.reactific.riddl.utils.Logger | ||
import org.eclipse.jgit.lib.ProgressMonitor | ||
|
||
import java.io.PrintStream | ||
|
||
case class DotWritingProgressMonitor(out: PrintStream, log: Logger, | ||
options: CommonOptions) | ||
extends ProgressMonitor { | ||
override def start(totalTasks: Int): Unit = { | ||
if (options.verbose) { log.info(s"Starting Fetch with $totalTasks tasks.") } | ||
else { out.print("\n.") } | ||
} | ||
|
||
override def beginTask(title: String, totalWork: Int): Unit = { | ||
if (options.verbose) { | ||
log.info(s"Starting Task '$title', $totalWork remaining.") | ||
} else { out.print(".") } | ||
} | ||
|
||
override def update(completed: Int): Unit = { | ||
if (options.verbose) { log.info(s"$completed tasks completed.") } | ||
else { out.print(".") } | ||
} | ||
|
||
override def endTask(): Unit = { | ||
if (options.verbose) { log.info(s"Task completed.") } | ||
else { out.println(".") } | ||
} | ||
|
||
override def isCancelled: Boolean = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...rc/test/scala/com/reactific/riddl/translator/onchange/DotWritingProgressMonitorTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright 2019 Ossum, Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.reactific.riddl.translator.onchange | ||
import com.reactific.riddl.language.CommonOptions | ||
import com.reactific.riddl.utils.StringBuildingPrintStream | ||
import com.reactific.riddl.utils.StringLogger | ||
import org.scalatest.matchers.must.Matchers | ||
import org.scalatest.wordspec.AnyWordSpec | ||
|
||
class DotWritingProgressMonitorTest extends AnyWordSpec with Matchers { | ||
def runTest(verbose: Boolean): (String, String) = { | ||
val log = StringLogger(1024) | ||
val capture = StringBuildingPrintStream() | ||
val monitor = | ||
DotWritingProgressMonitor(capture, log, CommonOptions(verbose = verbose)) | ||
monitor.start(3) | ||
def runTask(name: String, work: Int): Unit = { | ||
monitor.beginTask(name, work) | ||
for (i <- 1 to work) { monitor.update(i) } | ||
monitor.endTask() | ||
} | ||
runTask("One", 5) | ||
runTask("Two", 5) | ||
runTask("Three", 5) | ||
(capture.mkString(), log.toString()) | ||
|
||
} | ||
"DotWritingProgressMonitor" should { | ||
"product correct output for a set of tasks" in { | ||
val (capture, log) = runTest(true) | ||
capture mustBe empty | ||
log must be("""|[info] Starting Fetch with 3 tasks. | ||
|[info] Starting Task 'One', 5 remaining. | ||
|[info] 1 tasks completed. | ||
|[info] 2 tasks completed. | ||
|[info] 3 tasks completed. | ||
|[info] 4 tasks completed. | ||
|[info] 5 tasks completed. | ||
|[info] Task completed. | ||
|[info] Starting Task 'Two', 5 remaining. | ||
|[info] 1 tasks completed. | ||
|[info] 2 tasks completed. | ||
|[info] 3 tasks completed. | ||
|[info] 4 tasks completed. | ||
|[info] 5 tasks completed. | ||
|[info] Task completed. | ||
|[info] Starting Task 'Three', 5 remaining. | ||
|[info] 1 tasks completed. | ||
|[info] 2 tasks completed. | ||
|[info] 3 tasks completed. | ||
|[info] 4 tasks completed. | ||
|[info] 5 tasks completed. | ||
|[info] Task completed. | ||
|""".stripMargin) | ||
} | ||
"produce correct output in non-verbose mode" in { | ||
val (capture, log) = runTest(false) | ||
log mustBe empty | ||
capture must be(""" | ||
|........ | ||
|....... | ||
|....... | ||
|""".stripMargin) | ||
|
||
} | ||
} | ||
|
||
} |
Oops, something went wrong.