chiark / gitweb /
common: do not crash if the java_paths are not what is expected
authorHans-Christoph Steiner <hans@eds.org>
Thu, 11 Feb 2016 22:49:54 +0000 (23:49 +0100)
committerHans-Christoph Steiner <hans@eds.org>
Fri, 12 Feb 2016 07:33:21 +0000 (08:33 +0100)
Many commands work without the JDK installed, and it is also possible that
someone is using only JDK 8 or 9.

fdroidserver/common.py
tests/run-tests

index 120ef2aa0134f4f9de5d481e4c6d8c7e034da51c..4772abc88b62bc046c26cdc467937d23811181e5 100644 (file)
@@ -157,6 +157,8 @@ def fill_config_defaults(thisconfig):
                         thisconfig['java_paths'][m.group(1)] = d
 
     for java_version in ('7', '8', '9'):
+        if not java_version in thisconfig['java_paths']:
+            continue
         java_home = thisconfig['java_paths'][java_version]
         jarsigner = os.path.join(java_home, 'bin', 'jarsigner')
         if os.path.exists(jarsigner):
index c770091f2339583932a3702d550c5727fa250d34..7629f431bb107db1f5dd070ec4f7225c6d6f77ad 100755 (executable)
@@ -156,6 +156,41 @@ fi
 set -e
 
 
+#------------------------------------------------------------------------------#
+echo_header "ensure commands that don't need the JDK work without a JDK configed"
+
+REPOROOT=`create_test_dir`
+cd $REPOROOT
+mkdir repo
+mkdir metadata
+echo "License:GPL" >> metadata/fake.txt
+echo "Summary:Yup still fake" >> metadata/fake.txt
+echo "Categories:Internet" >> metadata/fake.txt
+echo "Description:" >> metadata/fake.txt
+echo "this is fake" >> metadata/fake.txt
+echo "." >> metadata/fake.txt
+
+# fake that no JDKs are available
+echo 'java_paths = {}' > config.py
+
+LOCAL_COPY_DIR=`create_test_dir`/fdroid
+mkdir -p $LOCAL_COPY_DIR/repo
+echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
+
+$fdroid checkupdates
+$fdroid gpgsign
+$fdroid lint
+$fdroid readmeta
+$fdroid rewritemeta fake
+$fdroid server update
+$fdroid scanner
+
+# run these to get their output, but the are not setup, so don't fail
+$fdroid build || true
+$fdroid import || true
+$fdroid install || true
+
+
 #------------------------------------------------------------------------------#
 echo_header "create a source tarball and use that to build a repo"