Skip to content

Commit

Permalink
Add integration tests which cover the entire DSL at once (closes #968)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsmith committed Dec 1, 2023
1 parent 5cc71f8 commit 2d4a6a2
Show file tree
Hide file tree
Showing 12 changed files with 376 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
certifi<=2023.9.9
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
six<=1.15.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from java import static_proxy


class MethodProxy(static_proxy()):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from java import static_proxy


class PropertyProxy(static_proxy()):
pass
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
plugins {
id 'com.android.application'
id 'com.chaquo.python'
}

android {
namespace "com.chaquo.python.test"
compileSdk 23

defaultConfig {
applicationId "com.chaquo.python.test"
minSdk 21
targetSdk 23
versionCode 1
versionName "0.0.1"
ndk {
abiFilters "x86"
}
}

flavorDimensions "variant"
productFlavors {
property { dimension "variant" }
method { dimension "variant" }
bpProperty { dimension "variant" }
bpMethod { dimension "variant" }
}
}

// defaultConfig properties (all other sub-properties are covered by productFlavors)
chaquopy.defaultConfig.extractPackages.add "ep_default_property"

// defaultConfig methods
chaquopy {
defaultConfig {
extractPackages("ep_default_method")
}
}

// productFlavors properties
def p = chaquopy.productFlavors.property
p.version = "3.9"
p.extractPackages.add "ep_property"
p.staticProxy.add "sp_property"
p.pip.install("certifi")
p.pip.options("-c", "constraints-certifi.txt")
p.pyc.src = true
p.pyc.pip = false
p.pyc.stdlib = false

// productFlavors methods
chaquopy {
productFlavors {
method {
version "3.10"
extractPackages("ep_method")
staticProxy("sp_method")
pip {
install("six")
options("-c", "constraints-six.txt")
}
pyc {
src false
pip true
stdlib false
}
}

// The easiest way to test buildPython is by causing a failure.
bpProperty {
buildPython = ["python-property"]
pyc.src = true
}
bpMethod {
buildPython("python-method")
pyc.src true
}

try {
getByName("nonexistent")
throw new GradleException("getByName unexpectedly succeeded")
} catch (UnknownDomainObjectException e) {}
}
}

// sourceSets properties
chaquopy.sourceSets.property.srcDir("src/ss_property")

// sourceSets methods
chaquopy {
sourceSets {
method {
srcDir("src/ss_method")
}

try {
getByName("nonexistent")
throw new GradleException("getByName unexpectedly succeeded")
} catch (UnknownDomainObjectException e) {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
plugins {
id 'com.android.application'
id 'com.chaquo.python'
}

android {
namespace "com.chaquo.python.test"
compileSdk 23

defaultConfig {
applicationId "com.chaquo.python.test"
minSdk 21
targetSdk 23
versionCode 1
versionName "0.0.1"
ndk {
abiFilters "x86"
}
}

flavorDimensions "variant"
productFlavors {
property { dimension "variant" }
method { dimension "variant" }
bpProperty { dimension "variant" }
bpMethod { dimension "variant" }
}
}

// defaultConfig properties (all other sub-properties are covered by productFlavors)
android.defaultConfig.python.extractPackages.add "ep_default_property"

// defaultConfig methods
android {
defaultConfig {
python {
extractPackages("ep_default_method")
}
}
}

// productFlavors properties
def p = android.productFlavors.property.python
p.version = "3.9"
p.extractPackages.add "ep_property"
p.staticProxy.add "sp_property"
p.pip.install("certifi")
p.pip.options("-c", "constraints-certifi.txt")
p.pyc.src = true
p.pyc.pip = false
p.pyc.stdlib = false

// productFlavors methods
android {
productFlavors {
method {
python {
version "3.10"
extractPackages("ep_method")
staticProxy("sp_method")
pip {
install("six")
options("-c", "constraints-six.txt")
}
pyc {
src false
pip true
stdlib false
}
}
}

// The easiest way to test buildPython is by causing a failure.
bpProperty {
python {
buildPython = ["python-property"]
pyc.src = true
}
}
bpMethod {
python {
buildPython("python-method")
pyc.src true
}
}

try {
getByName("nonexistent")
throw new GradleException("getByName unexpectedly succeeded")
} catch (UnknownDomainObjectException e) {}
}
}

// sourceSets properties
android.sourceSets.property.python.srcDir("src/ss_property")

// sourceSets methods
android {
sourceSets {
method {
python {
srcDir("src/ss_method")
}
}

try {
getByName("nonexistent")
throw new GradleException("getByName unexpectedly succeeded")
} catch (UnknownDomainObjectException e) {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
plugins {
id("com.android.application")
id("com.chaquo.python")
}

android {
namespace = "com.chaquo.python.test"
compileSdk = 23

defaultConfig {
applicationId = "com.chaquo.python.test"
minSdk = 21
targetSdk = 23
versionCode = 1
versionName = "0.0.1"
ndk {
abiFilters += "x86"
}
}

flavorDimensions += "variant"
productFlavors {
create("property") { dimension = "variant" }
create("method") { dimension = "variant" }
create("bpProperty") { dimension = "variant" }
create("bpMethod") { dimension = "variant" }
}
}

// defaultConfig properties (all other sub-properties are covered by productFlavors)
chaquopy.defaultConfig.extractPackages += "ep_default_property"

// defaultConfig methods
chaquopy {
defaultConfig {
extractPackages("ep_default_method")
}
}

// productFlavors properties
val p = chaquopy.productFlavors.getByName("property")
p.version = "3.9"
p.extractPackages += "ep_property"
p.staticProxy += "sp_property"
p.pip.install("certifi")
p.pip.options("-c", "constraints-certifi.txt")
p.pyc.src = true
p.pyc.pip = false
p.pyc.stdlib = false

// productFlavors methods
chaquopy {
productFlavors {
getByName("method") {
version = "3.10"
extractPackages("ep_method")
staticProxy("sp_method")
pip {
install("six")
options("-c", "constraints-six.txt")
}
pyc {
src = false
pip = true
stdlib = false
}
}

// The easiest way to test buildPython is by causing a failure.
getByName("bpProperty") {
buildPython = listOf("python-property")
pyc.src = true
}
getByName("bpMethod") {
buildPython("python-method")
pyc.src = true
}

try {
getByName("nonexistent")
throw GradleException("getByName unexpectedly succeeded")
} catch (e: UnknownDomainObjectException) {}
}
}

// sourceSets properties
chaquopy.sourceSets.getByName("property").srcDir("src/ss_property")

// sourceSets methods
chaquopy {
sourceSets {
getByName("method") {
srcDir("src/ss_method")
}

try {
getByName("nonexistent")
throw GradleException("getByName unexpectedly succeeded")
} catch (e: UnknownDomainObjectException) {}
}
}
Loading

0 comments on commit 2d4a6a2

Please sign in to comment.