fix android test app build and the script for android tests

address review comments
This commit is contained in:
blagoev 2017-12-14 12:17:49 +02:00
parent 106cf09c27
commit 97d695d615
11 changed files with 38 additions and 22 deletions

1
.gitignore vendored
View File

@ -56,3 +56,4 @@ packager_out.txt
build.log.*
realm-object-server/
tests/react-test-app/ios/out.txt
*.iml

View File

@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2016 Realm Inc.
// Copyright 2017 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -22,9 +22,7 @@ import {
Platform,
StyleSheet
} from 'react-native';
// import NavigationExperimental from 'react-native-deprecated-custom-components';
// const { NavBarHeight, TotalNavHeight } = NavigationExperimental.Navigator.NavigationBar.Styles.General;
const iOS = (Platform.OS == 'ios');

View File

@ -35,7 +35,6 @@ import ItemsScreen from './items-screen'
import realm from './realm';
import styles from './styles';
// import NavigationExperimental from 'react-native-deprecated-custom-components';
import { StackNavigator } from 'react-navigation';
import RNExitApp from 'react-native-exit-app-no-history';
@ -59,7 +58,7 @@ class HomeScreen extends React.Component {
this.todoLists.addListener((name, changes) => {
console.log("changed: " + JSON.stringify(changes));
if (params) {
console.error("params.json indicate a test run. Exiting application");
console.error("params.json indicates a test run. Exiting application");
RNExitApp.exitApp();
}
});
@ -67,7 +66,6 @@ class HomeScreen extends React.Component {
// Bind all the methods that we will be passing as props.
// this.renderScene = this.renderScene.bind(this);
this._addNewTodoList = this._addNewTodoList.bind(this);
this._onPressTodoList = this._onPressTodoList.bind(this);

View File

@ -64,6 +64,6 @@ shell.exec("adb shell am start -n io.realm.react.testapp/.MainActivity");
shell.popd();
shell.exec("adb shell \"logcat -c && logcat | grep -m 1 __REALM_REACT_ANDROID_TESTS_COMPLETED__\"");
shell.exec("adb shell \"logcat -c && logcat | grep -m 1 __REALM_JS_TESTS_COMPLETED__\"");
shell.exec("adb pull /sdcard/tests.xml");

View File

@ -66,7 +66,7 @@ stop_server() {
echo stopping server
if [[ ${SERVER_PID} -gt 0 ]] ; then
echo server is running. killing it
kill -9 ${SERVER_PID} || true
kill -9 ${SERVER_PID} >/dev/null 2>&1 || true
fi
}
@ -104,7 +104,7 @@ cleanup() {
open_chrome() {
if [ $CONFIGURATION == 'Release' ]; then
break
return;
fi
local dir
@ -152,6 +152,10 @@ xctest() {
echo "Shuttting down ${SIM_DEVICE_NAME} simulator. (device is not deleted. you can use it to debug the app)"
shutdown_ios_simulator
check_test_results $1
}
check_test_results() {
echo "Checking tests results"
if grep -q "REALM_FAILING_TESTS" $(pwd)/build/out.txt; then
echo "*** REALM JS TESTS FAILED. See tests results above ***"
@ -167,7 +171,7 @@ setup_ios_simulator() {
delete_ios_simulator >/dev/null 2>&1
#parse devices
IOS_RUNTIME=$(xcrun simctl list runtimes | grep -m1 -o '(com.apple.CoreSimulator.SimRuntime.iOS.*)' | sed 's/[()]//g')
IOS_RUNTIME=$(xcrun simctl list runtimes | grep -m1 -o 'com.apple.CoreSimulator.SimRuntime.iOS.*' | sed 's/[()]//g')
echo using iOS Runtime ${IOS_RUNTIME} to create new simulator ${SIM_DEVICE_NAME}
#create new test simulator
@ -271,21 +275,25 @@ case "$TARGET" in
[[ $CONFIGURATION == 'Debug' ]] && exit 0
XCPRETTY=''
pushd tests/react-test-app
pushd react-native/android
$(pwd)/gradlew publishAndroid
popd
pushd tests/react-test-app
npm install
echo "Resetting logcat"
# Despite the docs claiming -c to work, it doesn't, so `-T 1` alleviates that.
mkdir -p $(pwd)/build || true
adb logcat -c
adb logcat -T 1 | tee "$LOGCAT_OUT" &
adb logcat -T 1 | tee "$LOGCAT_OUT" | tee $(pwd)/build/out.txt &
./run-android.sh
echo "Start listening for Test completion"
while :; do
if grep -q "__REALM_REACT_ANDROID_TESTS_COMPLETED__" "$LOGCAT_OUT"; then
if grep -q "__REALM_JS_TESTS_COMPLETED__" "$LOGCAT_OUT"; then
break
else
echo "Waiting for tests."
@ -302,6 +310,7 @@ case "$TARGET" in
echo "********* File location: $(pwd)/tests.xml *********";
cat tests.xml
check_test_results ReactTests
;;
"node")
npm run check-environment

View File

@ -137,13 +137,13 @@ android {
}
dependencies {
compile project(':react-native-exception-handler')
compile project(':react-native-exit-app-no-history')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile project(":realm")
compile project(":react-native-fs")
compile project(':react-native-exception-handler')
compile project(':react-native-exit-app-no-history')
}
// Run this once to be able to run the application with BUCK

View File

@ -22,7 +22,7 @@ public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}

View File

@ -10,5 +10,6 @@ project(':react-native-fs').projectDir = new File(settingsDir, '../node_modules/
include ':react-native-exception-handler'
project(':react-native-exception-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-exception-handler/android')
include ':react-native-exit-app-no-history'
project(':react-native-exit-app-no-history').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-exit-app-no-history/android')

View File

@ -33,13 +33,13 @@ import { getTestNames, runTest } from './tests';
async function runTests() {
let testNames = getTestNames();
let rootXml = builder.create('testsuites');
let failingTests = [];
for (let suiteName in testNames) {
let itemTestsuite = rootXml.ele('testsuite');
let nbrTests = 0;
let nbrFailures = 0;
console.log('Starting ' + suiteName);
console.error('Starting ' + suiteName);
for (let testName of testNames[suiteName]) {
nbrTests++;
@ -51,6 +51,7 @@ async function runTests() {
await runTest(suiteName, testName);
}
catch (e) {
failingTests.push(`${suiteName}: ${testName} : Error ${e.message}`);
itemTest.ele('error', {'message': e.message, 'stacktrace': e.stack}, e.toString());
nbrFailures++;
}
@ -73,11 +74,19 @@ async function runTests() {
// write the unit tests reports
try {
await RNFS.writeFile('/sdcard/tests.xml', xmlString, 'utf8');
console.log('__REALM_REACT_ANDROID_TESTS_COMPLETED__');
console.log('__REALM_JS_TESTS_COMPLETED__');
if (failingTests.length !== 0) {
console.error('\n\nREALM_FAILING_TESTS\n');
console.error(failingTests);
}
}
catch (e) {
console.error(e);
}
finally {
console.warn("Realm Tests App finished. Exiting. Disable this to debug the app locally");
RNExitApp.exitApp();
}
}
class ReactTests extends React.Component {

View File

@ -99,7 +99,7 @@ async function runTests() {
//using console.log output is not shown in Release builds. using console.warn
console.warn(xmlString);
console.warn('__REALM_REACT_IOS_TESTS_COMPLETED__');
console.warn('__REALM_JS_TESTS_COMPLETED__');
if (failingTests.length !== 0) {
console.error('\n\nREALM_FAILING_TESTS\n');
console.error(failingTests);
@ -109,7 +109,7 @@ async function runTests() {
console.error(e);
}
finally {
console.warn("Realm iOS Tests App finished. Exiting. Disable this to debug the app locally");
console.warn("Realm Tests App finished. Exiting. Disable this to debug the app locally");
RNExitApp.exitApp();
}
}