Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sbt test returned failed tests: RemoveBlanksSuite and FoldRegexPatternsSuite #43

Open
windfall-s opened this issue Feb 21, 2022 · 2 comments
Assignees

Comments

@windfall-s
Copy link

Hi! A scala beginner here.

Based on the suggestion in page 4 of Chapter 1, I've executed sbt test under git-cloned programming-scala-book-code-examples/ directory.

I got the following errors. Does anyone have an idea on why it is returning errors?

 programming-scala-book-code-examples (master) $ sbt test
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
[info] welcome to sbt 1.5.5 (Homebrew Java 11.0.12)
[info] loading settings for project programming-scala-book-code-examples-build from plugins.sbt ...
[info] loading project definition from /Users/PCUser/dev/scala/programming-scala-book-code-examples/project
[info] loading settings for project root from build.sbt ...
[info] set current project to programming-scala-3rd-ed-code-examples (in build file:/Users/PCUser/dev/scala/programming-scala-book-code-examples/)
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
[info] + ZipCode.succeeds with zip integers between 1-99999 and extensions between 0-9999: OK, passed 100 tests.
[info] + ZipCode.succeeds with zip integers between 1-99999 and extension 0: OK, passed 100 tests.
[info] + ZipCode.succeeds with zip integers between 1-99999 and no extension: OK, passed 100 tests.
[info] + ZipCode.succeeds with zip string between 1-99999 and extensions between 0-9999: OK, passed 100 tests.
[info] + ZipCode.succeeds with zip string between 1-99999 and extension "0": OK, passed 100 tests.
[info] + ZipCode.succeeds with zip string between 1-99999 and extension "": OK, passed 100 tests.
[info] + ZipCode.succeeds with zip string between 1-99999 and no extension: OK, passed 100 tests.

...

progscala3.forcomps.RemoveBlanksSuite:
==> X progscala3.forcomps.RemoveBlanksSuite.RemoveBlanks removes blank lines in text  0.049s munit.FailException: /Users/PCUser/dev/scala/programming-scala-book-code-examples/src/test/scala/progscala3/forcomps/RemoveBlanksSuite.scala:13 assertion failed
12:      """  This is a       small
13:        |test   file""".stripMargin)
14:  }
    at munit.FunSuite.assert(FunSuite.scala:11)
    at progscala3.forcomps.RemoveBlanksSuite.$init$$$anonfun$1(RemoveBlanksSuite.scala:13)
==> X progscala3.forcomps.RemoveBlanksSuite.RemoveBlanks optionally compresses whitespace in text  0.002s munit.FailException: /Users/PCUser/dev/scala/programming-scala-book-code-examples/src/test/scala/progscala3/forcomps/RemoveBlanksSuite.scala:20 assertion failed
19:      """This is a small
20:        |test file""".stripMargin)
21:  }
    at munit.FunSuite.assert(FunSuite.scala:11)
    at progscala3.forcomps.RemoveBlanksSuite.$init$$$anonfun$2(RemoveBlanksSuite.scala:20)
==> X progscala3.forcomps.RemoveBlanksSuite.RemoveBlanks optionally prints line numbers from the original text  0.003s munit.FailException: /Users/PCUser/dev/scala/programming-scala-book-code-examples/src/test/scala/progscala3/forcomps/RemoveBlanksSuite.scala:27
26:      """   1: This is a small
27:        |   3: test file""".stripMargin, lines.mkString("\n"))
28:  }
   1: This is a small
   3: test file
    at munit.FunSuite.assert(FunSuite.scala:11)
    at progscala3.forcomps.RemoveBlanksSuite.$init$$$anonfun$3(RemoveBlanksSuite.scala:27)

progscala3.fp.datastructs.FoldRegexPatternsSuite:
==> X progscala3.fp.datastructs.FoldRegexPatternsSuite.Regex pattern matching used in a foldLeft  0.004s munit.FailException: /Users/PCUser/dev/scala/programming-scala-book-code-examples/src/test/scala/progscala3/fp/datastructs/FoldRegexPatternsSuite.scala:40 assertion failed
39:      Right("book.publisher" -> "O'Reilly"),
40:      Right("book.publication-year" -> "2021")))
41:  }
    at munit.FunSuite.assert(FunSuite.scala:11)
    at progscala3.fp.datastructs.FoldRegexPatternsSuite.$init$$$anonfun$1(FoldRegexPatternsSuite.scala:40)

...

[error] Failed: Total 233, Failed 4, Errors 0, Passed 229
[error] Failed tests:
[error]         progscala3.forcomps.RemoveBlanksSuite
[error]         progscala3.fp.datastructs.FoldRegexPatternsSuite
[error] (Test / test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 4 s, completed Feb 21, 2022, 4:40:42 PM

I'm using MacBook (Monterey 12.1) and here are my environment:

sbt --version
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
sbt version in this project: 1.5.5
sbt script version: 1.6.2

sbt:programming-scala-3rd-ed-code-examples> console
Welcome to Scala 3.1.0 (11.0.12, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
deanwampler pushed a commit that referenced this issue Apr 3, 2022
deanwampler pushed a commit that referenced this issue Apr 3, 2022
@deanwampler
Copy link
Owner

This could be caused by the default language setting for your computer. For example, on my Mac, I see this:

$ echo $LANG
en_US.UTF-8

Could you pull the latest version of the code in this repo and run it again? I added better error messages for both those tests, which should show more clearly what the two "expected" and "actual" strings really are.

@deanwampler deanwampler self-assigned this Apr 3, 2022
@deanwampler
Copy link
Owner

One more thing; another user reported an internationalization issue last year (if you are having the same issue...). See the Internationalization section in the README for a discussion. Let me know if it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants