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

Fix some warnings #3051

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class BintrayPublisher(
if !response.is2xx
} yield artifact -> s"Code: ${response.statusCode}, message: ${response.text()}"

val errorsByArtifact = errors.groupBy(_._1).mapValues(_.map(_._2)).toSeq
val errorsByArtifact = errors.groupBy(_._1).view.mapValues(_.map(_._2)).toSeq

if (errorsByArtifact.nonEmpty) {
throw new RuntimeException(
Expand Down
2 changes: 1 addition & 1 deletion contrib/bloop/src/mill/contrib/bloop/BloopImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class BloopImpl(ev: () => Evaluator, wd: os.Path) extends ExternalModule { outer
* under pwd/.bloop.
*/
def install() = T.command {
val res = T.traverse(computeModules)(_.bloop.writeConfig)()
val res = T.traverse(computeModules)(_.bloop.writeConfigFile())()
val written = res.map(_._2).map(_.path)
// Make bloopDir if it doesn't exists
if (!os.exists(bloopDir)) {
Expand Down
6 changes: 3 additions & 3 deletions contrib/bloop/test/src/mill/contrib/bloop/BloopTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ object BloopTests extends TestSuite {

def readBloopConf(jsonFile: String) =
_root_.bloop.config.read((workdir / ".bloop" / jsonFile).toNIO)
.right
.toOption
.get

def tests: Tests = Tests {
Expand Down Expand Up @@ -166,7 +166,7 @@ object BloopTests extends TestSuite {
}
"configAccessTest" - {
val (accessedConfig, _) =
testEvaluator(build.scalaModule.bloop.config).asSuccess.get.value.right.get
testEvaluator(build.scalaModule.bloop.config).asSuccess.get.value.toOption.get
assert(accessedConfig == scalaModuleConfig)
}
"noDepTest" - {
Expand Down Expand Up @@ -203,7 +203,7 @@ object BloopTests extends TestSuite {
val platform = p.platform.get.asInstanceOf[BloopConfig.Platform.Native]

val (clang, _) =
testEvaluator(build.scalanativeModule.nativeClang).asSuccess.get.value.right.get
testEvaluator(build.scalanativeModule.nativeClang).asSuccess.get.value.toOption.get

assert(name == "scalanativeModule")
assert(workspaceDir == Some(workdir.wrapped))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ object ProguardTests extends TestSuite {
}

test("should create a proguarded jar") - workspaceTest(proguard) { eval =>
try {
val Right((path, _)) = eval.apply(proguard.proguard)
assert(os.exists(path.path))
}
val Right((path, _)) = eval.apply(proguard.proguard)
assert(os.exists(path.path))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,22 @@ object VersionFileModuleTests extends TestSuite {

test("setReleaseVersion") - workspaceTest(versions: _*) { eval =>
val expected = eval(TestModule.versionFile.releaseVersion)
val write = eval(TestModule.versionFile.setReleaseVersion())
eval(TestModule.versionFile.setReleaseVersion())
val actual = eval(TestModule.versionFile.currentVersion)
assert(expected.value == actual.value)
}

test("setNextVersion") - workspaceTest(versions: _*) { eval =>
val bump = minor
val expected = eval(TestModule.versionFile.nextVersion(bump))
val write = eval(TestModule.versionFile.setNextVersion(bump))
eval(TestModule.versionFile.setNextVersion(bump))
val actual = eval(TestModule.versionFile.currentVersion)
assert(expected.value == actual.value)
}

test("setVersion") - workspaceTest(versions: _*) { eval =>
val expected = Version.Release(1, 2, 4)
val write = eval(TestModule.versionFile.setVersion(T.task(expected)))
eval(TestModule.versionFile.setVersion(T.task(expected)))
val actual = eval(TestModule.versionFile.currentVersion)
assert(actual.value == Right(expected))
}
Expand Down
6 changes: 5 additions & 1 deletion main/codesig/src/JvmModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import scala.collection.mutable.LinkedHashMap
import upickle.default.{ReadWriter, readwriter, stringKeyRW}

import scala.annotation.switch
import scala.collection.immutable.ArraySeq

// This file contains typed data structures representing the types and values
// found in the JVM bytecode: various kinds of types, method signatures, method
Expand Down Expand Up @@ -223,7 +224,10 @@ object JvmModel {
args.addOne(JType.read(s.substring(index, split + 1)))
index = split + 1
}
new Desc(args.result(), JType.read(s.substring(closeParenIndex + 1)))
new Desc(
ArraySeq.unsafeWrapArray(args.result()),
JType.read(s.substring(closeParenIndex + 1))
)
}

implicit val ordering: Ordering[Desc] = Ordering.by(_.pretty)
Expand Down
2 changes: 1 addition & 1 deletion main/codesig/src/ResolvedCalls.scala
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ object ResolvedCalls {
seen.add(current)
seenList.append(current)

for (next <- edges(current)) {
for (next <- edges(current).iterator) {
if (!seen.contains(next)) queued.enqueue(next)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package hello
// Taken from https://github.com/handsonscala/handsonscala/blob/ebc0367144513fc181281a024f8071a6153be424/examples/13.7%20-%20ParallelMergeSort/MergeSort.sc
import mainargs.main

object Main{
object Main {

import scala.concurrent._, duration.Duration.Inf, java.util.concurrent.Executors

implicit val ec = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(8))
implicit val ec: ExecutionContextExecutorService =
ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(8))

def mergeSortParallel[T: Ordering](items: IndexedSeq[T]): IndexedSeq[T] = {
Await.result(mergeSortParallel0(items), Inf)
Expand Down
10 changes: 7 additions & 3 deletions main/codesig/test/src/Util.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mill.codesig

import scala.collection.immutable.ArraySeq

object TestUtil {

def computeCodeSig(segments: Seq[String]) = {
Expand All @@ -11,9 +13,11 @@ object TestUtil {
// println("testClassFolder: " + testClassFolder)
CodeSig.compute(
os.walk(testClassFolder).filter(_.ext == "class"),
sys.env("MILL_TEST_CLASSPATH_" + segments.mkString("-"))
.split(",")
.map(os.Path(_)),
ArraySeq.unsafeWrapArray(
sys.env("MILL_TEST_CLASSPATH_" + segments.mkString("-"))
.split(",")
.map(os.Path(_))
),
(_, _) => false,
new Logger(Some(testLogFolder)),
() => None
Expand Down
3 changes: 2 additions & 1 deletion main/define/test/src/mill/define/ApplicativeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import utest._

import scala.annotation.compileTimeOnly
import scala.language.experimental.macros
import scala.language.implicitConversions

object ApplicativeTests extends TestSuite {
implicit def optionToOpt[T](o: Option[T]): Opt[T] = new Opt(o)
Expand Down Expand Up @@ -129,7 +130,7 @@ object ApplicativeTests extends TestSuite {
// apply() call is identical. It's up to the downstream zipMap()
// implementation to decide if it wants to dedup them or do other things.
val counter = new Counter()
def up = Opt { "hello" + counter() }
def up = Opt { s"hello${counter()}" }
val down = Opt { Seq(1, 2, 3).map(n => n + up() + up()) }
assert(down == Some(Seq("1hello1hello2", "2hello1hello2", "3hello1hello2")))
}
Expand Down
3 changes: 1 addition & 2 deletions main/define/test/src/mill/define/CacherTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ object CacherTests extends TestSuite {
val tests = Tests {
def eval[T <: TestUtil.BaseModule, V](mapping: T, v: Task[V])(implicit tp: TestPath) = {
val evaluator = new TestEvaluator(mapping)
evaluator(v).right.get._1
evaluator(v).toOption.get._1
}
def check(x: Any, y: Any) = assert(x == y)

"simpleDefIsCached" - {
Predef.assert(Base.value eq Base.value)
Expand Down
4 changes: 2 additions & 2 deletions main/eval/test/src/mill/eval/JavaCompileJarTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ object JavaCompileJarTests extends TestSuite {
evaluator.outPath / "jar.dest" / "out.jar",
"test.Foo"
).call(evaluator.outPath).out.text()
assert(executed == (31337 + 271828) + System.lineSeparator)
assert(executed == s"${31337 + 271828}${System.lineSeparator}")

for (i <- 0 until 3) {
// Build.run is not cached, so every time we eval it it has to
// re-evaluate
val Right((runOutput, evalCount)) = eval(Build.run("test.Foo"))
assert(
runOutput.out.text() == (31337 + 271828) + System.lineSeparator,
runOutput.out.text() == s"${31337 + 271828}${System.lineSeparator}",
evalCount == 1
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ object SmallModulesForTests extends TestSuite {
test("it should have a single publicModule") {
assert(publicModules.size == 1)
}
val mainModule = publicModules.head
val modulesLength = os.list(report.dest.path).length
test("my.Foo should not have its own file since it is in a separate package") {
assert(!os.exists(report.dest.path / "otherpackage.Foo.js"))
Expand Down
2 changes: 1 addition & 1 deletion scalalib/test/src/mill/scalalib/CycleTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package mill.scalalib
import mill.api.BuildScriptException
import mill.util.{TestEvaluator, TestUtil}
import utest.framework.TestPath
import utest.{TestSuite, Tests, compileError, intercept, test, assert}
import utest.{TestSuite, Tests, intercept, test, assert}

object CycleTests extends TestSuite {

Expand Down