Enabled embedded_launcher: true on python tests
We're making embedded_launcher: true the default, and these tests don't
currently work with it. They assume there are .py files on the
filesystem, but with embedded_launcher, the python source files will
not be extracted out of the test binary.
Bug: 331488610
Test: m treble_manifest_split_test treble_build_test && /ssd/aosp-main/out/host/linux-x86/nativetest64/treble_build_test/treble_build_test && /ssd/aosp-main/out/host/linux-x86/nativetest64/treble_manifest_split_test/treble_manifest_split_test
Change-Id: Ib2c144381b06577378e47f1b2529de44312eb623
diff --git a/build/Android.bp b/build/Android.bp
index 32c5bf5..9f62bbf 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -8,15 +8,15 @@
}
python_library_host {
- name: "treble_build_lib",
- defaults: ["treble_build_default"],
- srcs: [
- "sandbox/build_android_sandboxed.py",
- "sandbox/config.py",
- "sandbox/nsjail.py",
- "sandbox/overlay.py",
- "sandbox/rbe.py",
- ],
+ name: "treble_build_lib",
+ defaults: ["treble_build_default"],
+ srcs: [
+ "sandbox/build_android_sandboxed.py",
+ "sandbox/config.py",
+ "sandbox/nsjail.py",
+ "sandbox/overlay.py",
+ "sandbox/rbe.py",
+ ],
}
python_test_host {
@@ -39,4 +39,9 @@
test_options: {
unit_test: true,
},
+ version: {
+ py3: {
+ embedded_launcher: true,
+ },
+ },
}
diff --git a/build/test.py b/build/test.py
index b12934e..1955ca5 100644
--- a/build/test.py
+++ b/build/test.py
@@ -17,12 +17,17 @@
import unittest
import os
+import pkgutil
import sys
def run():
- start_dir = os.path.dirname(os.path.abspath(__file__))
- loader = unittest.TestLoader()
- suite = loader.discover(start_dir, pattern='*_test.py')
+ test_modules = [
+ mod.name
+ for mod in pkgutil.walk_packages()
+ if mod.name.endswith('_test')
+ ]
+
+ suite = unittest.defaultTestLoader.loadTestsFromNames(test_modules)
runner = unittest.TextTestRunner(verbosity=2)
result = runner.run(suite)
diff --git a/split/Android.bp b/split/Android.bp
index d742681..210e731 100644
--- a/split/Android.bp
+++ b/split/Android.bp
@@ -62,4 +62,9 @@
],
test_config: "test.xml",
test_suites: ["general-tests"],
+ version: {
+ py3: {
+ embedded_launcher: true,
+ },
+ },
}
diff --git a/split/manifest_diff_test.py b/split/manifest_diff_test.py
index ca1e742..0727877 100644
--- a/split/manifest_diff_test.py
+++ b/split/manifest_diff_test.py
@@ -15,7 +15,7 @@
import unittest
import xml.etree.ElementTree as ET
-import manifest_diff
+from treble.split import manifest_diff
class ManifestDiffTest(unittest.TestCase):
diff --git a/split/manifest_split_test.py b/split/manifest_split_test.py
index c07c870..27dd556 100644
--- a/split/manifest_split_test.py
+++ b/split/manifest_split_test.py
@@ -22,7 +22,7 @@
import unittest.mock
import xml.etree.ElementTree as ET
-import manifest_split
+from treble.split import manifest_split
class ManifestSplitTest(unittest.TestCase):
diff --git a/split/test.py b/split/test.py
index 36087ef..59a3d40 100644
--- a/split/test.py
+++ b/split/test.py
@@ -16,12 +16,17 @@
import unittest
import os
+import pkgutil
import sys
def run():
- start_dir = os.path.dirname(os.path.abspath(__file__))
- loader = unittest.TestLoader()
- suite = loader.discover(start_dir, pattern='*_test.py')
+ test_modules = [
+ mod.name
+ for mod in pkgutil.walk_packages()
+ if mod.name.endswith('_test')
+ ]
+
+ suite = unittest.defaultTestLoader.loadTestsFromNames(test_modules)
runner = unittest.TextTestRunner(verbosity=2)
result = runner.run(suite)
diff --git a/split/xml_diff_test.py b/split/xml_diff_test.py
index aef4562..82d5e62 100644
--- a/split/xml_diff_test.py
+++ b/split/xml_diff_test.py
@@ -15,7 +15,7 @@
import unittest
import xml.etree.ElementTree as ET
-import xml_diff
+from treble.split import xml_diff
class XmlDiffTest(unittest.TestCase):