Skip to content

Commit

Permalink
WIP 318 Test all levels of verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
ascheman committed Sep 16, 2024
1 parent f96bde7 commit d7c9f4e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class HscCommand implements Runnable {
}

static {
LogManager logManager = LogManager.getLogManager();
logManager.reset();
LogManager logManager = LogManager.getLogManager()
logManager.reset()

rootLogger = Logger.getLogger("org.aim42.htmlsanitycheck")
logger = Logger.getLogger(HscCommand.class.name)
Expand All @@ -72,7 +72,7 @@ class HscCommand implements Runnable {
}

@Option(names = ["-v", "--verbose"],
description = "Increase verbosity. Repeatable, cumulative -v -vv -vvv",
description = "Increase verbosity. Repeatable, cumulative, i.e., -v, -vv, -vvv, or -vvvv",
fallbackValue = "true", arity = "0..3")
private boolean[] verbosity

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,23 @@ class HscCommandSpec extends Specification {
errContent.toString().contains("Check HTML files for Sanity")
}

def "test with empty source directory"() {
@Unroll
// For misc. log levels
def "test with empty source directory and verbosity #args"() {
given:
TemporaryFolder testProjectDir = new TemporaryFolder()
testProjectDir.create()
SecurityManager originalSecurityManager = System.getSecurityManager()
SecurityManager mockSecurityManager = new NoExitSecurityMock(originalSecurityManager)
System.setSecurityManager(mockSecurityManager)
String[] args = [testProjectDir.root]
List<String> mainArgs = new ArrayList<>()
if (args) {
mainArgs.add(args)
}
mainArgs.add(testProjectDir.root)

when:
HscCommand.main(args)
HscCommand.main(mainArgs as String[])

then:
mockSecurityManager.exitCalled == 1
Expand All @@ -92,6 +98,15 @@ class HscCommandSpec extends Specification {

cleanup:
testProjectDir.delete()

where:
args << [
"",
"-v",
"-vv",
"-vvv",
"-vvvv"
]
}

def "test with valid HTML file"() {
Expand All @@ -103,7 +118,7 @@ class HscCommandSpec extends Specification {
HscCommand.main(args)

then:
File resultFile = new File (testResultsDir.root, 'index.html')
File resultFile = new File(testResultsDir.root, 'index.html')
resultFile.exists()
String result = resultFile.text
result.toString().contains("<div class=\"infoBox success\" id=\"successRate\"><div class=\"percent\">100%</div>successful</div>")
Expand All @@ -118,7 +133,7 @@ class HscCommandSpec extends Specification {
HscCommand.main(args)

then:
File resultFile = new File (testResultsDir.root, 'index.html')
File resultFile = new File(testResultsDir.root, 'index.html')
resultFile.exists()
String result = resultFile.text
result.toString().contains("<div class=\"infoBox failures\" id=\"successRate\"><div class=\"percent\">0%</div>successful</div>\n")
Expand Down

0 comments on commit d7c9f4e

Please sign in to comment.