mirror of
https://github.com/apache/cordova-android.git
synced 2025-04-03 05:11:59 +08:00
Merge pull request #442 from raphinesse/fix-tests
Fixes and cleanup for Java tests and CI
This commit is contained in:
commit
2106e2e081
1
.gitignore
vendored
1
.gitignore
vendored
@ -26,7 +26,6 @@ example
|
|||||||
/framework/javadoc-public
|
/framework/javadoc-public
|
||||||
/framework/javadoc-private
|
/framework/javadoc-private
|
||||||
/test/.externalNativeBuild
|
/test/.externalNativeBuild
|
||||||
/test/build.gradle
|
|
||||||
/test/gradle
|
/test/gradle
|
||||||
/test/gradlew
|
/test/gradlew
|
||||||
/test/gradlew.bat
|
/test/gradlew.bat
|
||||||
|
37
.travis.yml
37
.travis.yml
@ -2,27 +2,36 @@ language: android
|
|||||||
sudo: false
|
sudo: false
|
||||||
jdk:
|
jdk:
|
||||||
- oraclejdk8
|
- oraclejdk8
|
||||||
env:
|
|
||||||
global:
|
|
||||||
- ANDROID_TOOLS=${ANDROID_HOME}/tools
|
|
||||||
before_install:
|
|
||||||
- nvm install 6
|
|
||||||
# ensure at least gradle 3.3 is in place.
|
|
||||||
- wget http://services.gradle.org/distributions/gradle-3.3-bin.zip
|
|
||||||
- unzip gradle-3.3-bin.zip
|
|
||||||
- export GRADLE_HOME=$PWD/gradle-3.3
|
|
||||||
- export PATH=${GRADLE_HOME}/bin:${ANDROID_HOME}:${ANDROID_HOME}/emulator:${ANDROID_TOOLS}:${ANDROID_TOOLS}/bin:${ANDROID_HOME}/platform-tools:$PATH
|
|
||||||
- node --version
|
|
||||||
- gradle --version
|
|
||||||
- echo y | android --silent update sdk --no-ui --all --filter platform-tools,tools,build-tools-26.0.2,android-26,android-25,extra-google-m2repository,extra-android-m2repository
|
|
||||||
android:
|
android:
|
||||||
components:
|
components:
|
||||||
- tools
|
- build-tools-26.0.2
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
# Keep gradle from crapping all over the log
|
||||||
|
- TERM=dumb
|
||||||
|
matrix:
|
||||||
|
- nodejs_version=6
|
||||||
|
- nodejs_version=8
|
||||||
|
- nodejs_version=10
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
# Install a sdkmanager version that supports the --licenses switch and
|
||||||
|
# accept any Android SDK licenses. The output redirection prevents us from
|
||||||
|
# hitting the travis log size limit of 4MB which would fail the build.
|
||||||
|
- yes | sdkmanager tools > /dev/null
|
||||||
|
- yes | sdkmanager --licenses > /dev/null
|
||||||
|
|
||||||
|
- nvm install $nodejs_version
|
||||||
- npm install
|
- npm install
|
||||||
- npm install -g codecov
|
- npm install -g codecov
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
- gradle --version
|
||||||
|
- node --version
|
||||||
|
- npm --version
|
||||||
- npm test
|
- npm test
|
||||||
- npm run cover
|
- npm run cover
|
||||||
|
|
||||||
after_script:
|
after_script:
|
||||||
- codecov
|
- codecov
|
||||||
|
58
appveyor.yml
58
appveyor.yml
@ -1,38 +1,36 @@
|
|||||||
image:
|
|
||||||
- Previous Visual Studio 2015
|
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
ANDROID_HOME: "C:\\android"
|
ANDROID_HOME: "C:\\android"
|
||||||
matrix:
|
|
||||||
- nodejs_version: "4"
|
|
||||||
- nodejs_version: "6"
|
|
||||||
- nodejs_version: "8"
|
|
||||||
|
|
||||||
init:
|
# If the gradle daemon is used, the build hangs after generating the wrapper
|
||||||
- mkdir "%ANDROID_HOME%
|
GRADLE_OPTS: -Dorg.gradle.daemon=false
|
||||||
- cd "%ANDROID_HOME%"
|
|
||||||
- appveyor DownloadFile "https://dl.google.com/android/repository/tools_r25.2.3-windows.zip"
|
# URL for SDK Tools, Revision 26.1.1 (September 2017)
|
||||||
- 7z x "tools_r25.2.3-windows.zip" > nul
|
SDK_TOOLS_URL: https://dl.google.com/android/repository/sdk-tools-windows-3859397.zip
|
||||||
- cd "C:\projects\cordova-android"
|
|
||||||
|
matrix:
|
||||||
|
- nodejs_version: 6
|
||||||
|
- nodejs_version: 8
|
||||||
|
- nodejs_version: 10
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- choco install gradle -version 3.4.1
|
# Install Android SDK Tools
|
||||||
- gradle -version
|
- mkdir "%ANDROID_HOME%"
|
||||||
- echo y | "%ANDROID_HOME%\tools\android.bat" --silent update sdk --no-ui --all --filter platform-tools,tools,build-tools-26.0.2,android-26,android-25,extra-google-m2repository,extra-android-m2repository
|
- appveyor DownloadFile "%SDK_TOOLS_URL%" -FileName "%TMP%/sdk-tools.zip"
|
||||||
# on windows we need to accept sublicenses for the new tooling, wee. 30 is an arbitrary number,
|
- 7z x "%TMP%/sdk-tools.zip" -o"%ANDROID_HOME%" > nul
|
||||||
# but should be the maximum number of licenses we explicitly need to type "Y ENTER" for.
|
- set PATH=%PATH%;"%ANDROID_HOME%\tools\bin"
|
||||||
# also, the sdkmanager in all its glory leaks a bit of output to stderr, and powershell
|
|
||||||
# and appveyor interpret that as errors, and blows up. so, when piping in our "Y ENTER"
|
- yes 2> nul | sdkmanager --licenses > nul
|
||||||
# responses, we invoke cmd so we can redirect stderr to stdout, and tell it to --update itself.
|
- sdkmanager "build-tools;26.0.2"
|
||||||
- ps: for($i=0;$i -lt 30;$i++) { $response += "y`n"}; $response | cmd /c 'C:\android\tools\bin\sdkmanager.bat 2>&1' --update
|
|
||||||
- ps: Install-Product node $env:nodejs_version
|
- choco install gradle --version 3.4.1
|
||||||
- npm install
|
|
||||||
# below is a workaround on using gradle installed via choco on appveyor
|
- ps: Install-Product node $env:nodejs_version
|
||||||
- set path=C:\ProgramData\chocolatey\lib\gradle\tools\gradle-3.4.1\bin;%path%
|
- npm install
|
||||||
|
|
||||||
build: off
|
build: off
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- node --version
|
- gradle --version
|
||||||
- npm --version
|
- node --version
|
||||||
- npm test
|
- npm --version
|
||||||
|
- npm test
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
"unit-tests": "jasmine --config=spec/unit/jasmine.json",
|
"unit-tests": "jasmine --config=spec/unit/jasmine.json",
|
||||||
"cover": "istanbul cover --root bin --print detail jasmine -- --config=spec/unit/jasmine.json",
|
"cover": "istanbul cover --root bin --print detail jasmine -- --config=spec/unit/jasmine.json",
|
||||||
"e2e-tests": "jasmine --config=spec/e2e/jasmine.json",
|
"e2e-tests": "jasmine --config=spec/e2e/jasmine.json",
|
||||||
"java-unit-tests": "cd test && node run_java_unit_tests.js && cd ..",
|
"java-unit-tests": "node test/run_java_unit_tests.js",
|
||||||
"eslint": "eslint bin spec test"
|
"eslint": "eslint bin spec test"
|
||||||
},
|
},
|
||||||
"author": "Apache Software Foundation",
|
"author": "Apache Software Foundation",
|
||||||
@ -60,7 +60,7 @@
|
|||||||
"rewire": "^2.1.3"
|
"rewire": "^2.1.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4.0.0"
|
"node": ">=6.0.0"
|
||||||
},
|
},
|
||||||
"engineStrict": true
|
"engineStrict": true
|
||||||
}
|
}
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
#Wed Oct 25 11:17:25 PDT 2017
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
|
||||||
distributionPath=wrapper/dists
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
|
|
@ -22,26 +22,28 @@
|
|||||||
var Q = require('q');
|
var Q = require('q');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var superspawn = require('cordova-common').superspawn;
|
var superspawn = require('cordova-common').superspawn;
|
||||||
|
|
||||||
// First we make sure the gradlew helper file is built and ready.
|
|
||||||
var GradleBuilder = require('../bin/templates/cordova/lib/builders/GradleBuilder');
|
var GradleBuilder = require('../bin/templates/cordova/lib/builders/GradleBuilder');
|
||||||
var builder = new GradleBuilder(__dirname);
|
|
||||||
var needs_gradlew_built = builder.runGradleWrapper('gradle', 'build.gradle');
|
|
||||||
|
|
||||||
if (!needs_gradlew_built) {
|
Q.resolve()
|
||||||
// Due to interface of gradle builder, if the gradlew file already exists, `runGradleWrapper` returns undefined.
|
.then(_ => console.log('Preparing Gradle wrapper for Java unit tests.'))
|
||||||
// In this case, we will fill the gap and create a resolved promise here now, this way the next bit of code
|
.then(_ => new GradleBuilder(__dirname).runGradleWrapper('gradle'))
|
||||||
// will jump straight to running the tests
|
.then(_ => gradlew('--version'))
|
||||||
// TODO: maybe this should be done in GradleBuilder `runGradleWrapper` method instead?
|
|
||||||
needs_gradlew_built = Q.fcall(function () { return true; });
|
|
||||||
}
|
|
||||||
|
|
||||||
needs_gradlew_built.then(function () {
|
.then(_ => console.log('Gradle wrapper is ready. Running tests now.'))
|
||||||
return superspawn.spawn(path.join(__dirname, 'gradlew'), ['test'], {stdio: 'inherit'});
|
.then(_ => gradlew('test'))
|
||||||
}, function (err) {
|
.then(_ => console.log('Java unit tests completed successfully.'));
|
||||||
console.error('There was an error building the gradlew file:', err);
|
|
||||||
}).then(function () {
|
process.on('unhandledRejection', err => {
|
||||||
console.log('Tests completed successfully.');
|
// If err has a stderr property, we have seen the message already
|
||||||
}).fail(function (err) {
|
if (!('stderr' in err)) console.error(err.message);
|
||||||
console.error('Tests failed!', err);
|
console.error('JAVA UNIT TESTS FAILED!');
|
||||||
|
process.exitCode = err.code || 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function gradlew () {
|
||||||
|
const wrapperPath = path.join(__dirname, 'gradlew');
|
||||||
|
return superspawn.spawn(wrapperPath, Array.from(arguments), {
|
||||||
|
stdio: 'inherit',
|
||||||
|
cwd: __dirname
|
||||||
|
});
|
||||||
|
}
|
||||||
|
3
test/wrapper.gradle
Normal file
3
test/wrapper.gradle
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
wrapper {
|
||||||
|
gradleVersion = '4.4.1'
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user