mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Fix build script; remove some obsolete tests
This commit is contained in:
@@ -50,10 +50,6 @@ log_info() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fail() {
|
fail() {
|
||||||
if [ ! -z ${AVD_NAME} ]; then
|
|
||||||
stop_emulator
|
|
||||||
stop_gradle_daemon
|
|
||||||
fi
|
|
||||||
log_error "BUILD FAILED"
|
log_error "BUILD FAILED"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -64,22 +60,6 @@ if [ ! -z $RELEASE ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
start_emulator() {
|
|
||||||
log_info "Starting emulator ($AVD_NAME)"
|
|
||||||
$EMULATOR -avd ${AVD_NAME} -port ${AVD_SERIAL} -no-audio -no-window &
|
|
||||||
$ADB wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82'
|
|
||||||
}
|
|
||||||
|
|
||||||
stop_emulator() {
|
|
||||||
log_info "Stopping emulator"
|
|
||||||
$ADB emu kill
|
|
||||||
}
|
|
||||||
|
|
||||||
stop_gradle_daemon() {
|
|
||||||
log_info "Stopping gradle daemon"
|
|
||||||
$GRADLE --stop
|
|
||||||
}
|
|
||||||
|
|
||||||
run_adb_as_root() {
|
run_adb_as_root() {
|
||||||
log_info "Running adb as root"
|
log_info "Running adb as root"
|
||||||
$ADB root
|
$ADB root
|
||||||
@@ -113,12 +93,6 @@ build_instrumentation_apk() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
clean_output_dir() {
|
|
||||||
log_info "Cleaning output directory"
|
|
||||||
rm -rf ${OUTPUTS_DIR}
|
|
||||||
mkdir -p ${OUTPUTS_DIR}
|
|
||||||
}
|
|
||||||
|
|
||||||
uninstall_apk() {
|
uninstall_apk() {
|
||||||
log_info "Uninstalling existing APK"
|
log_info "Uninstalling existing APK"
|
||||||
$ADB uninstall ${PACKAGE_NAME}
|
$ADB uninstall ${PACKAGE_NAME}
|
||||||
@@ -152,10 +126,10 @@ run_instrumented_tests() {
|
|||||||
log_info "Running instrumented tests"
|
log_info "Running instrumented tests"
|
||||||
$ADB shell am instrument \
|
$ADB shell am instrument \
|
||||||
-r -e coverage true -e size $SIZE \
|
-r -e coverage true -e size $SIZE \
|
||||||
-w ${PACKAGE_NAME}.test/android.support.test.runner.AndroidJUnitRunner \
|
-w ${PACKAGE_NAME}.test/androidx.test.runner.AndroidJUnitRunner \
|
||||||
| tee ${OUTPUTS_DIR}/instrument.txt
|
| tee ${OUTPUTS_DIR}/instrument.txt
|
||||||
|
|
||||||
if grep FAILURES $OUTPUTS_DIR/instrument.txt; then
|
if grep "\(INSTRUMENTATION_STATUS_CODE.*-1\|FAILURES\)" $OUTPUTS_DIR/instrument.txt; then
|
||||||
log_error "Some instrumented tests failed"
|
log_error "Some instrumented tests failed"
|
||||||
fetch_images
|
fetch_images
|
||||||
fetch_logcat
|
fetch_logcat
|
||||||
@@ -225,19 +199,26 @@ run_tests() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parse_opts() {
|
parse_opts() {
|
||||||
OPTS=`getopt -o ur --long uninstall-first,release -n 'build.sh' -- "$@"`
|
OPTS=`getopt -o r --long release -n 'build.sh' -- "$@"`
|
||||||
if [ $? != 0 ] ; then exit 1; fi
|
if [ $? != 0 ] ; then exit 1; fi
|
||||||
eval set -- "$OPTS"
|
eval set -- "$OPTS"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-u | --uninstall-first ) UNINSTALL_FIRST=1; shift ;;
|
|
||||||
-r | --release ) RELEASE=1; shift ;;
|
-r | --release ) RELEASE=1; shift ;;
|
||||||
* ) break ;;
|
* ) break ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove_build_dir() {
|
||||||
|
rm -rfv build
|
||||||
|
rm -rfv android-base/build
|
||||||
|
rm -rfv android-pickers/build
|
||||||
|
rm -rfv uhabits-android/build
|
||||||
|
rm -rfv uhabits-core/build
|
||||||
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
build)
|
build)
|
||||||
shift; parse_opts $*
|
shift; parse_opts $*
|
||||||
@@ -248,33 +229,6 @@ case "$1" in
|
|||||||
#generate_coverage_badge
|
#generate_coverage_badge
|
||||||
;;
|
;;
|
||||||
|
|
||||||
ci-tests)
|
|
||||||
if [ -z $3 ]; then
|
|
||||||
cat <<- END
|
|
||||||
Usage: $0 ci-tests AVD_NAME AVD_SERIAL [options]
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
AVD_NAME name of the virtual android device to start
|
|
||||||
AVD_SERIAL adb port to use (e.g. 5560)
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-u --uninstall-first Uninstall existing APK first
|
|
||||||
-r --release Test release APK, instead of debug
|
|
||||||
END
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
shift; AVD_NAME=$1
|
|
||||||
shift; AVD_SERIAL=$1
|
|
||||||
shift; parse_opts $*
|
|
||||||
ADB="${ADB} -s emulator-${AVD_SERIAL}"
|
|
||||||
|
|
||||||
start_emulator
|
|
||||||
run_tests medium
|
|
||||||
stop_emulator
|
|
||||||
stop_gradle_daemon
|
|
||||||
;;
|
|
||||||
|
|
||||||
medium-tests)
|
medium-tests)
|
||||||
shift; parse_opts $*
|
shift; parse_opts $*
|
||||||
run_tests medium
|
run_tests medium
|
||||||
@@ -299,20 +253,27 @@ case "$1" in
|
|||||||
install_apk
|
install_apk
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
clean)
|
||||||
|
remove_build_dir
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
cat <<- END
|
cat <<END
|
||||||
Usage: $0 <command> [options]
|
Usage: $0 <command> [options]
|
||||||
Builds, installs and tests Loop Habit Tracker
|
Builds, installs and tests Loop Habit Tracker
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
ci-tests Start emulator silently, run tests then kill emulator
|
|
||||||
local-tests Run all tests on connected device
|
|
||||||
install Install app on connected device
|
|
||||||
fetch-images Fetches failed view test images from device
|
|
||||||
accept-images Copies fetched images to corresponding assets folder
|
accept-images Copies fetched images to corresponding assets folder
|
||||||
|
build Build APK and run JVM tests
|
||||||
|
clean Remove build directory
|
||||||
|
fetch-images Fetches failed view test images from device
|
||||||
|
install Install app on connected device
|
||||||
|
large-tests Run large-sized tests on connected device
|
||||||
|
medium-tests Run medium-sized tests on connected device
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-r --release Build and test release APK, instead of debug
|
-r --release Build and test release APK, instead of debug
|
||||||
END
|
END
|
||||||
exit 1
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Loop Habit Tracker.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by the
|
|
||||||
* Free Software Foundation, either version 3 of the License, or (at your
|
|
||||||
* option) any later version.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
||||||
* more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.isoron.uhabits.tasks;
|
|
||||||
|
|
||||||
import androidx.test.filters.*;
|
|
||||||
import androidx.test.runner.*;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.*;
|
|
||||||
import org.junit.*;
|
|
||||||
import org.junit.runner.*;
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
@MediumTest
|
|
||||||
public class ExportCSVTaskTest extends BaseAndroidTest
|
|
||||||
{
|
|
||||||
@Before
|
|
||||||
@Override
|
|
||||||
public void setUp()
|
|
||||||
{
|
|
||||||
super.setUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Test
|
|
||||||
// public void testExportCSV() throws Throwable
|
|
||||||
// {
|
|
||||||
// fixtures.purgeHabits(habitList);
|
|
||||||
// fixtures.createShortHabit();
|
|
||||||
//
|
|
||||||
// List<Habit> selected = new LinkedList<>();
|
|
||||||
// for (Habit h : habitList) selected.add(h);
|
|
||||||
// File outputDir = new AndroidDirFinder(targetContext).getFilesDir("CSV");
|
|
||||||
// assertNotNull(outputDir);
|
|
||||||
//
|
|
||||||
// taskRunner.execute(
|
|
||||||
// new ExportCSVTask(habitList, selected, outputDir, archiveFilename -> {
|
|
||||||
// assertThat(archiveFilename, is(not(nullValue())));
|
|
||||||
// File f = new File(archiveFilename);
|
|
||||||
// assertTrue(f.exists());
|
|
||||||
// assertTrue(f.canRead());
|
|
||||||
// }));
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Loop Habit Tracker.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by the
|
|
||||||
* Free Software Foundation, either version 3 of the License, or (at your
|
|
||||||
* option) any later version.
|
|
||||||
*
|
|
||||||
* Loop Habit Tracker is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
||||||
* more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.isoron.uhabits.tasks;
|
|
||||||
|
|
||||||
import androidx.test.filters.*;
|
|
||||||
import androidx.test.runner.*;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.*;
|
|
||||||
import org.junit.*;
|
|
||||||
import org.junit.runner.*;
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
@MediumTest
|
|
||||||
public class ExportDBTaskTest extends BaseAndroidTest
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
@Before
|
|
||||||
public void setUp()
|
|
||||||
{
|
|
||||||
super.setUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Test
|
|
||||||
// public void testExportCSV() throws Throwable
|
|
||||||
// {
|
|
||||||
// ExportDBTask task =
|
|
||||||
// new ExportDBTask(targetContext, new AndroidDirFinder(targetContext),
|
|
||||||
// filename ->
|
|
||||||
// {
|
|
||||||
// assertNotNull(filename);
|
|
||||||
// File f = new File(filename);
|
|
||||||
// assertTrue(f.exists());
|
|
||||||
// assertTrue(f.canRead());
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// taskRunner.execute(task);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user