Commit 53dfdb4b authored by Mike JS. Choi's avatar Mike JS. Choi Committed by Carola Nitz

Tests: Add code coverage

Add MobileVLCKit Testscheme for code coverage
Add Gemfilea and  rake task for MobileVLCKit code coverage
Add MobileVLCKit code coverage task on CircleCI
parent 5e8cc5ee
......@@ -11,6 +11,13 @@ jobs:
steps:
- checkout
- restore_cache:
key: v1-gems-{{ checksum "Gemfile.lock" }}
- run: bundle check || bundle install --path .bundle
- save_cache:
key: v1-gems-{{ checksum "Gemfile.lock" }}
paths:
- .bundle
- restore_cache:
key: libvlc-{{ checksum "compileAndBuildVLCKit.sh" }}
- run:
......@@ -27,4 +34,11 @@ jobs:
name: Run Tests
command: |
rake test:ios
- run:
name: Generate Coverage Reports
command: |
rake codecov:ios
- store_artifacts:
path: Tests/Coverage
destination: Coverage
GEM
remote: https://rubygems.org/
specs:
rouge (2.0.7)
xcpretty (0.2.8)
rouge (~> 2.0.7)
PLATFORMS
ruby
DEPENDENCIES
xcpretty
BUNDLED WITH
1.16.2
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CA0301CA20ADFD2500452BB8"
BuildableName = "MobileVLCKitTests.xctest"
BlueprintName = "MobileVLCKitTests"
ReferencedContainer = "container:MobileVLCKit.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
......@@ -21,19 +21,26 @@
#
# ------------------------------------------------------------- Constants ------
SDK_SIM = 'iphonesimulator11.3'
SDK_SIM_DEST = "'platform=iOS Simulator,name=iPhone 7,OS=11.3'"
PROJECT_MOBILE = 'MobileVLCKit.xcodeproj'
SDK_SIM_IOS = 'iphonesimulator11.3'
SDK_SIM_DEST_IOS = "'platform=iOS Simulator,name=iPhone 7,OS=11.3'"
SCHEME_IOS = 'MobileVLCKitTests'
PROJECT_IOS = 'MobileVLCKit.xcodeproj'
VLC_FLAGS_IOS = '-dva x86_64'
DERIVED_DATA_PATH = 'DerivedData'
COVERAGE_REPORT_PATH = 'Tests/Coverage'
XCPRETTY = "xcpretty && exit ${PIPESTATUS[0]}"
# ----------------------------------------------------------------- Tasks ------
desc 'Build VLCKit (iOS)'
desc 'Build MobileVLCKit'
task 'build:vlckit:ios' do
puts 'Building VLCKit (iOS)'
puts 'Building MobileVLCKit'
plugin_file = 'Resources/MobileVLCKit/vlc-plugins-iPhone.h'
required_dirs = ['./libvlc/vlc/install-iPhoneSimulator', './libvlc/vlc/build-iPhoneSimulator']
......@@ -48,11 +55,30 @@ end
desc 'Run MobileVLCKit tests'
task 'test:ios' do
puts 'Running tests for MobileVLCKit'
sh "xcodebuild -project #{PROJECT_IOS} -scheme #{SCHEME_IOS} -sdk #{SDK_SIM} -destination #{SDK_SIM_DEST} test"
sh "xcodebuild -derivedDataPath #{DERIVED_DATA_PATH}/#{SCHEME_IOS} -project #{PROJECT_MOBILE} -scheme #{SCHEME_IOS} -sdk #{SDK_SIM_IOS} -destination #{SDK_SIM_DEST_IOS} test | #{XCPRETTY}"
end
desc 'Generate code coverage reports (MobileVLCKit)'
task 'codecov:ios' do
puts 'Generating code coverage reports (MobileVLCKit)'
generate_coverage(SCHEME_IOS)
end
# ------------------------------------------------------------- Functions ------
def generate_coverage(scheme)
report_name = "#{COVERAGE_REPORT_PATH}/#{scheme}_coverage.txt"
scheme_derived_data = "#{DERIVED_DATA_PATH}/#{scheme}"
if Dir.exist?(scheme_derived_data)
sh "mkdir -p #{COVERAGE_REPORT_PATH}"
sh "xcrun xccov view #{scheme_derived_data}/Logs/Test/*.xccovreport > #{report_name}"
sh "cat #{report_name}"
else
puts "#{scheme} has not been tested yet. Please run its tests first"
end
end
def dirs_exist?(directories)
directories.each do |dir|
return false unless Dir.exist?(dir)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment