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 java compile warning, again #3762

Merged
merged 20 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:

# Most of these integration tests should not depend on which mode they
# are run in, so just run them in `local`
- java-version: '11'
- java-version: '17'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new test emits some benign warnings on Java 11, so just run on java 17 instead

millargs: "'integration.{failure,feature,ide}.__.local.testCached'"

# These invalidation tests need to be exercised in both execution modes
Expand Down
9 changes: 9 additions & 0 deletions integration/feature/full-run-logs/resources/build.mill
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package build
import mill._, javalib._

object `package` extends RootModule with JavaModule {
def ivyDeps = Agg(
ivy"net.sourceforge.argparse4j:argparse4j:0.9.0",
ivy"org.apache.commons:commons-text:1.12.0"
)
}
33 changes: 33 additions & 0 deletions integration/feature/full-run-logs/resources/src/foo/Foo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package foo;

import org.apache.commons.text.StringEscapeUtils;
import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;


public class Foo{
public static String generateHtml(String text){
return "<h1>" + StringEscapeUtils.escapeHtml4(text) + "</h1>";
}
public static void main(String[] args) {
ArgumentParser parser = ArgumentParsers.newFor("template").build()
.defaultHelp(true)
.description("Inserts text into a HTML template");

parser.addArgument("-t", "--text")
.required(true)
.help("text to insert");

Namespace ns = null;
try {
ns = parser.parseArgs(args);
}catch(Exception e){
System.out.println(e.getMessage());
System.exit(1);
}

System.out.println(generateHtml(ns.getString("text")));
}
}
53 changes: 53 additions & 0 deletions integration/feature/full-run-logs/src/FullRunLogsTests.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package mill.integration

import mill.testkit.UtestIntegrationTestSuite
import utest._

// Run simple commands on a simple build and check their entire output,
// ensuring we don't get spurious warnings or logging messages slipping in
object FullRunLogsTests extends UtestIntegrationTestSuite {

def tests: Tests = Tests {
test("noticker") - integrationTest { tester =>
import tester._

val res = eval(("--ticker", "false", "run", "--text", "hello"))
res.isSuccess ==> true
assert(res.out == "<h1>hello</h1>")
assert(
res.err.replace('\\', '/') ==
s"""[build.mill] [info] compiling 1 Scala source to ${tester.workspacePath}/out/mill-build/compile.dest/classes ...
|[build.mill] [info] done compiling
|[info] compiling 1 Java source to ${tester.workspacePath}/out/compile.dest/classes ...
|[info] done compiling""".stripMargin
)
}
test("ticker") - integrationTest { tester =>
import tester._

val res = eval(("--ticker", "true", "run", "--text", "hello"))
res.isSuccess ==> true
assert(res.out == "[46] <h1>hello</h1>")

val expectedErrorRegex =
s"""==================================================== run --text hello ================================================
|======================================================================================================================
|[build.mill-56/60] compile
|[build.mill-56] [info] compiling 1 Scala source to ${tester.workspacePath}/out/mill-build/compile.dest/classes ...
|[build.mill-56] [info] done compiling
|[40/46] compile
|[40] [info] compiling 1 Java source to ${tester.workspacePath}/out/compile.dest/classes ...
|[40] [info] done compiling
|[46/46] run
|[46/46] ============================================ run --text hello ============================================= ?s
|======================================================================================================================"""
.stripMargin
.replace('\\', '/')
.split('?')
.map(java.util.regex.Pattern.quote)
.mkString("[\\d]+")

assert(expectedErrorRegex.r.matches(res.err.replace('\\', '/')))
}
}
}
11 changes: 2 additions & 9 deletions main/define/src/mill/define/Discover.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ object Discover {
seen.add(tpe)
for {
m <- tpe.members.toList.sortBy(_.name.toString)
if !m.isType
memberTpe = m.typeSignature
if memberTpe.resultType <:< typeOf[mill.define.Module] && memberTpe.paramLists.isEmpty
} rec(memberTpe.resultType)
Expand Down Expand Up @@ -141,15 +142,7 @@ object Discover {
}
if overridesRoutes._1.nonEmpty || overridesRoutes._2.nonEmpty || overridesRoutes._3.nonEmpty
} yield {
val lhs0 = discoveredModuleType match {
// Explicitly do not de-alias type refs, so type aliases to deprecated
// types do not result in spurious deprecation warnings appearing
case tr: TypeRef => tr
// Other types are fine
case _ => discoveredModuleType.typeSymbol.asClass.toType
}

val lhs = q"classOf[$lhs0]"
val lhs = q"classOf[${discoveredModuleType.typeSymbol.asClass.toType}]"

// by wrapping the `overridesRoutes` in a lambda function we kind of work around
// the problem of generating a *huge* macro method body that finally exceeds the
Expand Down
Loading