first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.ktfmt)
}
repositories { mavenCentral() }
group = "com.facebook.react"
dependencies { implementation(libs.junit) }
java { targetCompatibility = JavaVersion.VERSION_11 }
kotlin { jvmToolchain(17) }
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
apiVersion.set(KotlinVersion.KOTLIN_1_8)
// See comment above on JDK 11 support
jvmTarget.set(JvmTarget.JVM_11)
allWarningsAsErrors.set(
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
)
}
}
tasks.withType<Test>().configureEach {
testLogging {
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
showStackTraces = true
}
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.tests
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
/**
* A JUnit [TestRule] to override values of [System.getProperties] with the support of the [WithOs]
* annotation.
*/
class OsRule : TestRule {
private var retainOs: String? = null
private var retainArch: String? = null
override fun apply(statement: Statement, description: Description): Statement {
return object : Statement() {
override fun evaluate() {
val annotation = description.annotations.filterIsInstance<WithOs>().firstOrNull()
annotation?.os?.propertyName?.let { osName ->
retainOs = System.getProperty(OS_NAME_KEY)
System.setProperty(OS_NAME_KEY, osName)
}
annotation?.arch?.let { arch ->
if (arch.isNotBlank()) {
retainArch = System.getProperty(OS_ARCH_KEY)
System.setProperty(OS_ARCH_KEY, arch)
}
}
try {
statement.evaluate()
} finally {
retainOs?.let { System.setProperty(OS_NAME_KEY, it) }
retainArch?.let { System.setProperty(OS_ARCH_KEY, it) }
}
}
}
}
companion object {
const val OS_NAME_KEY = "os.name"
const val OS_ARCH_KEY = "os.arch"
}
}

View File

@@ -0,0 +1,17 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.tests
/** Annotation to specify an Operating System to override the "os.name" System Property. */
@Retention(AnnotationRetention.RUNTIME) annotation class WithOs(val os: OS, val arch: String = "")
enum class OS(val propertyName: String) {
WIN("Windows"),
MAC("MacOs"),
LINUX("Linux"),
}