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

More summary improvements. #122

Merged
merged 13 commits into from
Dec 11, 2022
12 changes: 11 additions & 1 deletion src/main/resources/manuals/default/test262/filtered.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
"built-ins/AsyncGeneratorPrototype/return/return-state-completed-broken-promise",
"built-ins/AsyncGeneratorPrototype/return/return-suspendedStart-broken-promise"
],
"yet tests": [
"not yet categorized tests": [
"built-ins/Array/prototype/sort/stability-2048-elements",
"built-ins/AsyncFromSyncIteratorPrototype/next/iterator-result-rejected",
"built-ins/AsyncFromSyncIteratorPrototype/throw/iterator-result",
Expand Down Expand Up @@ -365,6 +365,7 @@
"built-ins/Promise/all/iter-arg-is-string-resolve",
"built-ins/Promise/allSettled/iter-arg-is-string-resolve",
"built-ins/Promise/any/iter-arg-is-empty-string-reject",
"built-ins/RegExp/lookBehind/sliced-strings",
"built-ins/Set/prototype/entries/returns-iterator",
"built-ins/Set/prototype/entries/returns-iterator-empty",
"built-ins/Set/prototype/values/returns-iterator",
Expand All @@ -391,6 +392,15 @@
"built-ins/String/prototype/S15.5.4_A2",
"built-ins/String/prototype/concat/S15.5.4.6_A3",
"built-ins/String/prototype/constructor/S15.5.4.1_A1_T2",
"built-ins/String/prototype/matchAll/length",
"built-ins/String/prototype/matchAll/name",
"built-ins/String/prototype/matchAll/prop-desc",
"built-ins/String/prototype/matchAll/regexp-is-null",
"built-ins/String/prototype/matchAll/regexp-is-undefined",
"built-ins/String/prototype/matchAll/regexp-matchAll-invocation",
"built-ins/String/prototype/matchAll/regexp-matchAll-not-callable",
"built-ins/String/prototype/matchAll/regexp-prototype-has-no-matchAll",
"built-ins/String/prototype/matchAll/this-val-non-obj-coercible",
"built-ins/Symbol/prototype/Symbol.toPrimitive/redefined-symbol-wrapper-ordinary-toprimitive",
"built-ins/Symbol/prototype/Symbol.toPrimitive/removed-symbol-wrapper-ordinary-toprimitive",
"language/computed-property-names/class/static/generator-prototype",
Expand Down
16 changes: 0 additions & 16 deletions src/main/resources/manuals/default/test262/in-progress.json

This file was deleted.

9 changes: 7 additions & 2 deletions src/main/scala/esmeta/error/NotSupported.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
package esmeta.error

// not supported errors
case class NotSupported(msg: String) extends ESMetaError(msg, "NotSupported")
/** not supported errors */
case class NotSupported(reasonPath: NotSupported.ReasonPath)
extends ESMetaError(s"${reasonPath.mkString("/")}", "NotSupported")
object NotSupported:
type Reason = String
type ReasonPath = List[Reason]
def apply(reason: Reason): NotSupported = NotSupported(List(reason))
8 changes: 4 additions & 4 deletions src/main/scala/esmeta/error/Test262Error.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package esmeta.error

import esmeta.LINE_SEP
import esmeta.util.SummaryElem
import esmeta.util.Summary

sealed abstract class Test262Error(msg: String)
extends ESMetaError(msg, s"Test262Error")

// Test262 failure
case class Test262Fail(fails: SummaryElem)
/** Test262 failure */
case class Test262Fail(fails: Summary.Elem)
extends Test262Error(
s"${fails.size} tests are failed:" + LINE_SEP +
fails.elements.toList.sorted.mkString(LINE_SEP),
fails.all.sorted.mkString(LINE_SEP),
)
4 changes: 2 additions & 2 deletions src/main/scala/esmeta/interpreter/Interpreter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class Interpreter(
case v => throw NoNt(nt, v)
st.allocList(eval(ast).asAst.getItems(name).map(AstValue(_)))
case EYet(msg) =>
throw NotSupported(msg)
throw NotSupported(List("metalanguage", msg))
case EContains(list, elem, field) =>
val l = eval(list).getList(list, st)
val e = eval(elem)
Expand Down Expand Up @@ -666,7 +666,7 @@ object Interpreter {
Str(ESValueParser.parseTRVTemplateTail(str))
case (_, "Contains") => Bool(false)
case ("RegularExpressionLiteral", name) =>
throw NotSupported(s"RegularExpressionLiteral.$sdoName")
throw NotSupported(List("RegExp", sdoName))
case _ =>
throw InvalidAstProp(lex, Str(sdoName))
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/esmeta/phase/Test262Test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ case object Test262Test extends Phase[CFG, Summary] {
)

// if summary has failed test case, throws an exception
if (summary.fail > 0) throw Test262Fail(summary.fails)
if (summary.failCount > 0) throw Test262Fail(summary.fail)

// return summary
summary
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/esmeta/state/util/Stringifier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Stringifier(detail: Boolean, location: Boolean) {
app :> "context: " >> st.context
given Rule[List[String]] = iterableRule("[", ", ", "]")
app :> "call-stack: "
app.wrapIterable("[", "]")(st.callStack)
app.wrapIterable("[", ",", "]")(st.callStack)
app :> "globals: " >> st.globals
app :> "heap: " >> st.heap
}
Expand Down
32 changes: 11 additions & 21 deletions src/main/scala/esmeta/test262/Test262.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package esmeta.test262
import esmeta.*
import esmeta.cfg.CFG
import esmeta.error.{NotSupported, InvalidExit, UnexpectedParseResult}
import esmeta.error.NotSupported.*
import esmeta.es.*
import esmeta.es.util.*
import esmeta.interpreter.Interpreter
Expand Down Expand Up @@ -70,17 +71,19 @@ case class Test262(
def getProgressBar(
name: String,
targetTests: List[Test],
removed: Iterable[(Test, ReasonPath)] = Nil,
useProgress: Boolean = false,
useErrorHandler: Boolean = true,
): ProgressBar[Test] = ProgressBar(
msg = s"Run Test262 $name tests",
iterable = targetTests,
notSupported = removed,
getName = (test, _) => test.relName,
errorHandler = (e, summary, name) =>
if (useErrorHandler) e match
case NotSupported(msg) => summary.yets += s"$name - $msg"
case _: TimeoutException => summary.timeouts += name
case e: Throwable => summary.fails += s"$name - ${e.getMessage}"
case NotSupported(reasons) => summary.notSupported.add(name, reasons)
case _: TimeoutException => summary.timeout.add(name)
case e: Throwable => summary.fail.add(name, e.getMessage)
else throw e,
verbose = useProgress,
)
Expand All @@ -106,6 +109,7 @@ case class Test262(
val progressBar = getProgressBar(
name = "eval",
targetTests = targetTests,
removed = removed,
useProgress = useProgress,
useErrorHandler = multiple,
)
Expand All @@ -121,7 +125,6 @@ case class Test262(
logForTests(
name = "eval",
progressBar = progressBar,
removed = removed,
postSummary = if (useCoverage) cov.toString else "",
log = log && multiple,
)(
Expand Down Expand Up @@ -158,14 +161,14 @@ case class Test262(
val progressBar = getProgressBar(
name = "parse",
targetTests = targetTests,
removed = removed,
useProgress = useProgress,
)

// run tests with logging
logForTests(
name = "parse",
progressBar = progressBar,
removed = removed,
log = log,
)(
// check parsing result with its corresponding code
Expand Down Expand Up @@ -211,7 +214,6 @@ case class Test262(
private def logForTests(
name: String,
progressBar: ProgressBar[Test],
removed: Map[String, List[Test]],
postSummary: => String = "",
log: Boolean = false,
)(
Expand All @@ -223,31 +225,19 @@ case class Test262(

// setting for logging
if (log)
println(s"- Logging to $logDir...")
mkdir(logDir)
dumpFile(spec.versionString, s"$logDir/ecma262-version")
dumpFile(ESMeta.currentVersion, s"$logDir/esmeta-version")
summary.timeouts.setPath(s"$logDir/timeout.log")
summary.yets.setPath(s"$logDir/yet.log")
summary.fails.setPath(s"$logDir/fail.log")
summary.passes.setPath(s"$logDir/pass.log")

// run tests
for (test <- progressBar) check(test)

// logging after tests
if (log)
summary.close
val removed_total = removed.foldLeft(0)(_ + _._2.length)
summary.dumpTo(logDir)
val summaryStr =
s"- total: ${summary.total + removed_total}$LINE_SEP" +
s"- removed: ${removed_total}$LINE_SEP" +
removed.foldLeft("") {
case (acc, (s, i)) => acc + s" - $s: ${i.length}$LINE_SEP"
}
+ (if (postSummary.isEmpty) s"$summary$LINE_SEP"
else
s"$summary$LINE_SEP$postSummary$LINE_SEP")
if (postSummary.isEmpty) s"$summary"
else s"$summary$LINE_SEP$postSummary"
dumpFile(s"Test262 $name test summary", summaryStr, s"$logDir/summary")
}
object Test262 extends Git(TEST262_DIR)
6 changes: 1 addition & 5 deletions src/main/scala/esmeta/test262/util/ManualConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import java.io.File

case class ManualConfig(
filtered: Map[String, List[String]],
inProgress: Map[String, List[String]],
supportedFeatures: List[String],
)
object ManualConfig {
Expand All @@ -20,11 +19,8 @@ object ManualConfig {
val filtered = fileMap
.get("filtered.json")
.fold(Map())(readJson[Map[String, List[String]]])
val inProgress = fileMap
.get("in-progress.json")
.fold(Map())(readJson[Map[String, List[String]]])
val supportedFeatures = fileMap
.get("supported-features.json")
.fold(Nil)(readJson[List[String]])
ManualConfig(filtered, inProgress, supportedFeatures)
ManualConfig(filtered, supportedFeatures)
}
Loading