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 proto test nondeterminism #239

Merged
merged 1 commit into from
Mar 28, 2024
Merged
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 @@ -36,21 +36,37 @@ trait ProtocInvocationHelper {

private def loadProtoFiles(directories: String*): List[(String, String)] = {
directories.flatMap { d =>
val dir = new File(getClass.getResource(d).getPath())
dir.listFiles().toSeq.filter(_.getName().endsWith(".proto")).map { file =>
(d + "/" + file.getName) -> Source
.fromFile(file)
.getLines()
.mkString("\n")
}
val maybeDir: Option[File] =
getClass()
.getClassLoader()
.getResources(d)
.asScala
.collectFirst {
// do not include resources from external jars
// here we are targeting the resources that come from
// our local build
case url if !url.getProtocol.startsWith("jar") =>
new File(url.getPath())
}

maybeDir.toList
.flatMap(
_.listFiles().toSeq.filter(_.getName().endsWith(".proto")).map {
file =>
(d + "/" + file.getName) -> Source
.fromFile(file)
.getLines()
.mkString("\n")
}
)
}.toList
}

def generateFileSet(files: Seq[(String, String)]): Seq[FileDescriptor] = {
val tmpDir = Files.createTempDirectory("validation").toFile
val extraFiles = loadProtoFiles(
"/google/protobuf/",
"/alloy/protobuf/"
"google/protobuf",
"alloy/protobuf"
)
val allFiles = files ++ extraFiles
val fileNames = allFiles.map { case (name, content) =>
Expand Down
Loading