Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Sep 9, 2024
1 parent 8cbed7f commit 5e037fb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
2 changes: 2 additions & 0 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ object upack extends Module {
def moduleDeps = Seq(upickle.core.jvm())
object test extends CommonTestModule{
def moduleDeps = super.moduleDeps ++ Seq(ujson.jvm().test, upickle.core.jvm().test)
def forkEnv = super.forkEnv() ++ Map("EXAMPLE_JSON" -> exampleJson().path.toString)
}
}

Expand Down Expand Up @@ -182,6 +183,7 @@ object ujson extends Module{

object test extends CommonTestModule{
def moduleDeps = super.moduleDeps ++ Seq(upickle.core.jvm().test)
def forkEnv = super.forkEnv() ++ Map("EXAMPLE_JSON" -> exampleJson().path.toString)
}
}

Expand Down
6 changes: 4 additions & 2 deletions mill
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
set -e

if [ -z "${DEFAULT_MILL_VERSION}" ] ; then
DEFAULT_MILL_VERSION=0.11.2
DEFAULT_MILL_VERSION=0.11.12
fi

if [ -z "$MILL_VERSION" ] ; then
Expand Down Expand Up @@ -53,7 +53,9 @@ if [ -z "$MILL_MAIN_CLI" ] ; then
fi

MILL_FIRST_ARG=""
if [ "$1" = "--bsp" ] || [ "$1" = "-i" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--repl" ] || [ "$1" = "--help" ] ; then

# first arg is a long flag for "--interactive" or starts with "-i"
if [ "$1" = "--bsp" ] || [ "${1#"-i"}" != "$1" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--repl" ] || [ "$1" = "--help" ] ; then
# Need to preserve the first position of those listed options
MILL_FIRST_ARG=$1
shift
Expand Down
7 changes: 4 additions & 3 deletions ujson/test/src-jvm/ujson/ExampleJsonTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import java.nio.file.{Files, Paths}
import utest._

object ExampleJsonTests extends TestSuite {
def check(name: String) = {
TestUtil.checkParse(new String(Files.readAllBytes(Paths.get("exampleJson", name))), true)
}
def check(name: String) = TestUtil.checkParse(
new String(Files.readAllBytes(Paths.get(sys.env("EXAMPLE_JSON"), name))),
true
)
val tests = Tests {
test - check("australia-abc.json")
test - check("bitcoin.json")
Expand Down
2 changes: 1 addition & 1 deletion upack/test/src-jvm/upack/ExampleJsonTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import utest._
object ExampleJsonTests extends TestSuite {
def check(name: String) = {
val msgPack = ujson
.read(Files.readAllBytes(Paths.get("exampleJson", name)))
.read(Files.readAllBytes(Paths.get(sys.env("EXAMPLE_JSON"), name)))
.transform(new MsgPackWriter(new java.io.ByteArrayOutputStream))
.toByteArray
TestUtil.checkParse(msgPack, true)
Expand Down
7 changes: 4 additions & 3 deletions upack/test/src-jvm/upack/MsgPackJvmTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ object MsgPackJvmTests extends TestSuite{

// Taken from:
// https://github.com/msgpack/msgpack-ruby/tree/a22d8268f82e0f2ae95f038285af43ce5971810e/spec
val casesJson = "upack/test/resources/cases.json"
val casesMsg = "upack/test/resources/cases.msg"
val casesCompactMsg = "upack/test/resources/cases_compact.msg"
val resources = sys.env("MILL_TEST_RESOURCE_FOLDER")
val casesJson = resources + "/cases.json"
val casesMsg = resources + "/cases.msg"
val casesCompactMsg = resources + "/cases_compact.msg"
val expectedJson = ujson.read(readBytes(casesJson))
// println("---msgs---")
val msg = readMsgs(casesMsg)
Expand Down

0 comments on commit 5e037fb

Please sign in to comment.