Skip to content

Commit

Permalink
Update unit tests and fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
rthic23 committed Jul 17, 2024
1 parent 5b967e9 commit 35e3a32
Show file tree
Hide file tree
Showing 63 changed files with 845 additions and 58 deletions.
30 changes: 14 additions & 16 deletions ern-core/test/android-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ describe('android.js', () => {
reactNativeVersion: '0.72.0',
});
expect(versions).deep.equal({
androidBuildToolsPlugin: '7.4.2',
androidGradlePlugin: '0.72.11',
androidGradlePlugin: '7.4.2',
rnGradlePlugin: '0.72.11',
androidxAppcompactVersion: android.DEFAULT_ANDROIDX_APPCOMPACT_VERSION,
androidxLifecycleExtrnsionsVersion:
android.DEFAULT_ANDROIDX_LIFECYCLE_EXTENSIONS_VERSION,
Expand All @@ -237,9 +237,8 @@ describe('android.js', () => {
reactNativeVersion: '0.64.0',
});
expect(versions).deep.equal({
androidBuildToolsPlugin:
android.DEFAULT_BUILD_TOOLS_GRADLE_PLUGIN_VERSION,
androidGradlePlugin: android.DEFAULT_RN_GRADLE_PLUGIN_VERSION,
androidGradlePlugin: android.DEFAULT_GRADLE_PLUGIN_VERSION,
rnGradlePlugin: android.DEFAULT_RN_GRADLE_PLUGIN_VERSION,
androidxAppcompactVersion: android.DEFAULT_ANDROIDX_APPCOMPACT_VERSION,
androidxLifecycleExtrnsionsVersion:
android.DEFAULT_ANDROIDX_LIFECYCLE_EXTENSIONS_VERSION,
Expand All @@ -261,9 +260,8 @@ describe('android.js', () => {
reactNativeVersion: '0.63.0',
});
expect(versions).deep.equal({
androidBuildToolsPlugin:
android.DEFAULT_BUILD_TOOLS_GRADLE_PLUGIN_VERSION,
androidGradlePlugin: android.DEFAULT_RN_GRADLE_PLUGIN_VERSION,
androidGradlePlugin: android.DEFAULT_GRADLE_PLUGIN_VERSION,
rnGradlePlugin: android.DEFAULT_RN_GRADLE_PLUGIN_VERSION,
androidxAppcompactVersion: android.DEFAULT_ANDROIDX_APPCOMPACT_VERSION,
androidxLifecycleExtrnsionsVersion:
android.DEFAULT_ANDROIDX_LIFECYCLE_EXTENSIONS_VERSION,
Expand All @@ -282,17 +280,17 @@ describe('android.js', () => {

it('should return default versions along with user provided versions', () => {
const versions = android.resolveAndroidVersions({
androidBuildToolsPlugin: '7.4.2',
androidGradlePlugin: '0.72.11',
androidGradlePlugin: '7.4.2',
rnGradlePlugin: '0.72.11',
kotlinVersion: '1.4.0',
minSdkVersion: '15',
sourceCompatibility: 'VERSION_1_9',
targetCompatibility: 'VERSION_1_9',
reactNativeVersion: '0.72.0',
});
expect(versions).deep.equal({
androidBuildToolsPlugin: '7.4.2',
androidGradlePlugin: '0.72.11',
androidGradlePlugin: '7.4.2',
rnGradlePlugin: '0.72.11',
androidxAppcompactVersion: android.DEFAULT_ANDROIDX_APPCOMPACT_VERSION,
androidxLifecycleExtrnsionsVersion:
android.DEFAULT_ANDROIDX_LIFECYCLE_EXTENSIONS_VERSION,
Expand All @@ -311,8 +309,8 @@ describe('android.js', () => {

it('should return only user provided versions', () => {
const versions = android.resolveAndroidVersions({
androidBuildToolsPlugin: '7.4.2',
androidGradlePlugin: '3.0.0',
androidGradlePlugin: '7.4.2',
rnGradlePlugin: '3.0.0',
androidxAppcompactVersion: '1.0.0',
androidxLifecycleExtrnsionsVersion: '2.0.0',
buildToolsVersion: '27.0.0',
Expand All @@ -327,8 +325,8 @@ describe('android.js', () => {
reactNativeVersion: '0.63.0',
});
expect(versions).deep.equal({
androidBuildToolsPlugin: '7.4.2',
androidGradlePlugin: '3.0.0',
androidGradlePlugin: '7.4.2',
rnGradlePlugin: '3.0.0',
androidxAppcompactVersion: '1.0.0',
androidxLifecycleExtrnsionsVersion: '2.0.0',
buildToolsVersion: '27.0.0',
Expand Down
47 changes: 44 additions & 3 deletions ern-runner-gen-android/test/AndroidRunnerGenerator-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { sameDirContent } from 'ern-util-dev';
import { AndroidRunnerGenerator } from 'ern-runner-gen-android';
import { RunnerGeneratorConfig } from 'ern-runner-gen';

describe('AndroidRunnerGenerator', () => {
describe('Test AndroidRunnerGenerator for RN version 0.67.x', () => {
const fixtureRunnerPath = path.join(
__dirname,
'fixtures',
'simple-android-runner',
'simple-android-runner-rn-67',
);
const generatedRunnerPath = tmp.dirSync({ unsafeCleanup: true }).name;
process.chdir(generatedRunnerPath);
Expand All @@ -25,7 +25,48 @@ describe('AndroidRunnerGenerator', () => {
},
mainMiniAppName: 'dummy',
outDir: generatedRunnerPath,
reactNativeVersion: '0.59.8',
reactNativeVersion: '0.67.0',
targetPlatform: 'android',
};

it('should generate simple-android-runner fixture given same configuration', async () => {
await new AndroidRunnerGenerator().generate(generatorConfig);
assert(
sameDirContent(fixtureRunnerPath, generatedRunnerPath),
'Generated Android Runner project differs from simple-android-runner fixture',
);
});

it('should re-generate configuration of simple-android-runner fixture given same configuration', async () => {
await new AndroidRunnerGenerator().regenerateRunnerConfig(generatorConfig);
assert(
sameDirContent(fixtureRunnerPath, generatedRunnerPath),
'Generated Android Runner project differs from simple-android-runner fixture',
);
});
});

describe('Test AndroidRunnerGenerator for RN version 0.72.x', () => {
const fixtureRunnerPath = path.join(
__dirname,
'fixtures',
'simple-android-runner-rn-72',
);
const generatedRunnerPath = tmp.dirSync({ unsafeCleanup: true }).name;
process.chdir(generatedRunnerPath);

const generatorConfig: RunnerGeneratorConfig = {
extra: {
androidConfig: {
artifactId: 'runner-ern-container-dummy',
groupId: 'com.walmartlabs.ern',
packageFilePath: 'com/walmartlabs/ern/dummy',
packageName: 'com.walmartlabs.ern.dummy',
},
},
mainMiniAppName: 'dummy',
outDir: generatedRunnerPath,
reactNativeVersion: '0.72.0',
targetPlatform: 'android',
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
apply plugin: 'com.android.application'
apply plugin: "com.facebook.react"

/**
* The preferred build flavor of JavaScriptCore (JSC)
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'

android {
compileSdkVersion 31
buildToolsVersion "31.0.0"
compileSdkVersion 33
buildToolsVersion "33.0.0"
defaultConfig {
applicationId "com.walmartlabs.ern.dummy"
minSdkVersion 19
targetSdkVersion 30
minSdkVersion 21
targetSdkVersion 33
versionCode 1
versionName "1.0"
}
Expand All @@ -17,8 +31,8 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
// Need this to avoid build conflict with jsr version which comes with react-native
configurations.all {
Expand All @@ -28,15 +42,14 @@ android {
lintOptions {
disable 'InvalidPackage'
}
packagingOptions {
pickFirst "lib/armeabi-v7a/libc++_shared.so"
pickFirst "lib/arm64-v8a/libc++_shared.so"
pickFirst "lib/x86/libc++_shared.so"
pickFirst "lib/x86_64/libc++_shared.so"
}
}

dependencies {
// Recompile this dependency on every build as it can be updated at any time (snapshot)
implementation('com.walmartlabs.ern:runner-ern-container-dummy:1.0.0') { changing = true }
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" android:exported="false"/>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.android.tools.build:gradle:7.0.2'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand All @@ -22,3 +23,22 @@ org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.182.0

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64

# Use this property to enable support to the new architecture.
# This will allow you to use TurboModules and the Fabric render in
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=false

# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,10 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -205,6 +209,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
Loading

0 comments on commit 35e3a32

Please sign in to comment.