Skip to content

Commit

Permalink
enable its in windows
Browse files Browse the repository at this point in the history
package artifacts
  • Loading branch information
Jorge Costa authored and Jorge Costa committed Jan 10, 2016
1 parent 3c4b7df commit c02e00b
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ before_script:
script:
- mvn install -DskipTests=true
- mvn test
- RAILS_ENV=production PATH=$PATH:/tmp/sonar-runner-2.4/bin behave
- RAILS_ENV=production PATH=$PATH:/tmp/sonar-runner-2.4/bin TestDataFolder=~/sonar-cxx/integration-tests/testdata behave

after_failure:
- cat $SONARHOME/logs/sonar.log
Expand Down
32 changes: 31 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ install:
)
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\maven-bin.zip", "C:\maven")
}
if (!(Test-Path -Path "C:\sonar-runner" )) {
(new-object System.Net.WebClient).DownloadFile(
'http://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner-dist/2.4/sonar-runner-dist-2.4.zip',
'C:\sonar-runner-dist.zip'
)
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\sonar-runner-dist.zip", "C:\sonar-runner")
}
if (!(Test-Path -Path "C:\sonarqube-4.5.6" )) {
(new-object System.Net.WebClient).DownloadFile(
'https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-4.5.6.zip',
'C:\sonarqube-4.5.6.zip'
)
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\sonarqube-4.5.6.zip", "C:\sonarqube-4.5.6")
}
- ps: |
If ($env:Platform -Match "x86") {
$env:PCRE_PLATFORM="Win32"
Expand All @@ -24,19 +38,35 @@ install:
$env:VCVARS_PLATFORM="amd64"
$env:LANG_PLATFORM="-x64"
}
- cmd: SET PATH=C:\maven\apache-maven-3.2.5\bin;%JAVA_HOME%\bin;%PATH%
- cmd: SET PATH=C:\maven\apache-maven-3.2.5\bin;%JAVA_HOME%\bin;C:\sonar-runner\sonar-runner-2.4\bin;%PATH%
- cmd: SET SONARHOME=C:\sonarqube-4.5.6\sonarqube-4.5.6
- cmd: SET TestDataFolder=C:\projects\sonar-cxx\integration-tests\testdata
- cmd: SET

build_script:
- dir
- mkdir C:\WINDOWS\system32\config\systemprofile\AppData\Local\Temp
- cd C:\WINDOWS\system32\config\systemprofile\AppData\Local\
- dir
- cd C:\projects\sonar-cxx
- dir
- C:\Python27\Scripts\pip.exe install requests
- C:\Python27\Scripts\pip.exe install behave
- C:\Python27\Scripts\pip.exe install colorama
- mvn clean install
- C:\Python27\Scripts\behave.exe
cache:
- C:\maven\
- C:\Users\appveyor\.m2
artifacts:
- path: 'sonar-cxx-plugin\target\sonar-cxx-plugin-0.9.5-SNAPSHOT.jar'
- path: 'sslr-cxx-toolkit\target\sslr-cxx-toolkit-0.9.5-SNAPSHOT.jar'
- path: '*_project_.log'
- path: 'C:\sonarqube-4.5.6\sonarqube-4.5.6\logs\*'
on_failure:
- ps: Get-ChildItem cxx-squid\target\surefire-reports\*.txt | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- ps: Get-ChildItem cxx-checks\target\surefire-reports\*.txt | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- ps: Get-ChildItem sonar-cxx-plugin\target\surefire-reports\*.txt | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- ps: Get-ChildItem *_project_.log | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- ps: Get-ChildItem C:\sonarqube-4.5.6\sonarqube-4.5.6\logs\* | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }

8 changes: 6 additions & 2 deletions integration-tests/features/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import re
import os
import sys

SONAR_ERROR_RE = re.compile(".* ERROR .*")
SONAR_WARN_RE = re.compile(".* WARN .*")
Expand Down Expand Up @@ -53,8 +54,11 @@ def analyseloglines(lines, toignore=None):
badlines.append(line)
errors += 1
elif isSonarWarning(line, toingore_re):
badlines.append(line)
warnings += 1
if "JOURNAL_FLUSHER" not in line:
sys.stdout.write("found warning '%s'" % line)
badlines.append(line)
warnings += 1

return badlines, errors, warnings


Expand Down
76 changes: 67 additions & 9 deletions integration-tests/features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
from subprocess import Popen, PIPE, check_call
from common import analyselog, sonarlog

from tempfile import mkstemp
from shutil import move
from os import remove, close

SONAR_URL = "http://localhost:9000"
INDENT = " "
BASEDIR = os.path.dirname(os.path.realpath(__file__))
Expand Down Expand Up @@ -155,7 +159,7 @@ def start_sonar(sonarhome):
sys.stdout.write(INDENT + "starting SonarQube ... ")
sys.stdout.flush()
now = time.time()
Popen(start_script(sonarhome), stdout=PIPE, shell=os.name == "nt")
start_script(sonarhome)
if not wait_for_sonar(50, is_webui_up):
sys.stdout.write(RED + "FAILED\n" + RESET)
return False
Expand All @@ -167,8 +171,19 @@ def start_sonar(sonarhome):

def stop_sonar(sonarhome):
if platform.system() == "Windows":
sys.stdout.write(YELLOW + "Cannot stop SonarQube automaticly on Windows. Please do it manually.\n" + RESET)
return
if platform.machine() == "x86_64":
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "UninstallNTService.bat")]
check_call(command, stdout=PIPE, shell=os.name == "nt")
elif platform.machine() == "i686":
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-32", "UninstallNTService.bat")]
check_call(command, stdout=PIPE, shell=os.name == "nt")
elif platform.machine() == "AMD64":
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "UninstallNTService.bat")]
check_call(command, stdout=PIPE, shell=os.name == "nt")

if not wait_for_sonar(30, is_webui_down):
sys.stdout.write(RED + "FAILED\n" + RESET)
return False

sys.stdout.write(INDENT + "stopping SonarQube ... ")
sys.stdout.flush()
Expand All @@ -185,24 +200,65 @@ class UnsupportedPlatform(Exception):
def __init__(self, msg):
super(UnsupportedPlatform, self).__init__(msg)


def replace(file_path, pattern, subst):
#Create temp file
fh, abs_path = mkstemp()
with open(abs_path,'w') as new_file:
with open(file_path) as old_file:
for line in old_file:
new_file.write(line.replace(pattern, subst))
close(fh)
#Remove original file
remove(file_path)
#Move new file
move(abs_path, file_path)

def start_script(sonarhome):
command = None

if platform.system() == "Linux":
script = linux_script(sonarhome)
if script:
command = [script, "start"]

Popen(command, stdout=PIPE, shell=os.name == "nt")
elif platform.system() == "Windows":
replace(os.path.join(sonarhome, "conf", "sonar.properties"), "#sonar.path.data=data", "sonar.path.data=" + os.path.join(sonarhome,"data").replace("\\","/"))
replace(os.path.join(sonarhome, "conf", "sonar.properties"), "#sonar.path.temp=temp", "sonar.path.temp=" + os.path.join(sonarhome,"temp").replace("\\","/"))
replace(os.path.join(sonarhome, "conf", "wrapper.conf"), "wrapper.java.additional.1=-Djava.awt.headless=true", "wrapper.java.additional.1=-Djava.awt.headless=true -Djava.io.tmpdir=" + os.path.join(sonarhome,"temp").replace("\\","/"))

if platform.machine() == "x86_64":
command = ["start", "cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "StartSonar.bat")]
sys.stdout.write(GREEN + "Install Service...\n")
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "InstallNTService.bat")]
check_call(command, stdout=PIPE, shell=os.name == "nt")
sys.stdout.write(GREEN + "Install Service... Ok\n" + RESET)
sys.stdout.write(GREEN + "Start Service... \n")
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "StartNTService.bat")]
Popen(command, stdout=PIPE, shell=os.name == "nt")
sys.stdout.write(GREEN + "Start Service... Ok \n")
elif platform.machine() == "i686":
command = ["start", "cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-32", "StartSonar.bat")]
sys.stdout.write(GREEN + "Install Service...\n")
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-32", "InstallNTService.bat")]
check_call(command, stdout=PIPE, shell=os.name == "nt")
sys.stdout.write(GREEN + "Install Service... Ok\n" + RESET)
sys.stdout.write(GREEN + "Start Service... \n")
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-32", "StartNTService.bat")]
Popen(command, stdout=PIPE, shell=os.name == "nt")
sys.stdout.write(GREEN + "Start Service... Ok \n" + RESET)
elif platform.machine() == "AMD64":
command = ["start", "cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "StartSonar.bat")]
sys.stdout.write(GREEN + "Install Service...\n")
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "InstallNTService.bat")]
check_call(command, stdout=PIPE, shell=os.name == "nt")
sys.stdout.write(GREEN + "Install Service... Ok\n" + RESET)
sys.stdout.write(GREEN + "Start Service... \n")
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "StartNTService.bat")]
Popen(command, stdout=PIPE, shell=os.name == "nt")
sys.stdout.write(GREEN + "Start Service... Ok \n" + RESET)

sys.stdout.write(GREEN + "Start on windows done... Ok \n" + RESET)
elif platform.system() == "Darwin":
command = [os.path.join(sonarhome, "bin/macosx-universal-64/sonar.sh"), "start"]

Popen(command, stdout=PIPE, shell=os.name == "nt")
if command is None:
msg = "Dont know how to find the start script for the platform %s-%s" % (platform.system(), platform.machine())
raise UnsupportedPlatform(msg)
Expand All @@ -213,13 +269,15 @@ def start_script(sonarhome):
def stop_script(sonarhome):
command = None


if platform.system() == "Linux":
script = linux_script(sonarhome)
if script:
command = [script, "stop"]
elif platform.system() == "Darwin":
command = [os.path.join(sonarhome, "bin/macosx-universal-64/sonar.sh"), "stop"]

elif platform.system() == "Windows":
command = ["cmd", "/c", "dir"]
if command is None:
msg = "Dont know how to find the stop script for the platform %s-%s" % (platform.system(), platform.machine())
raise UnsupportedPlatform(msg)
Expand Down
13 changes: 12 additions & 1 deletion integration-tests/features/steps/test_execution_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import re
import json
import requests
import platform
from requests.auth import HTTPBasicAuth
import subprocess
import shutil
Expand Down Expand Up @@ -63,7 +64,17 @@ def step_impl(context, project):
for key, name in data.iteritems():
if name == "Sonar way - c++":
context.profile_key = key


@given(u'platform is not "{plat}"')
def step_impl(context, plat):
if platform.system() == plat:
context.scenario.skip(reason='scenario meant to run only in specified platform')

@given(u'platform is "{plat}"')
def step_impl(context, plat):
if platform.system() != plat:
context.scenario.skip(reason='scenario meant to run only in specified platform')

@given(u'rule "{rule}" is enabled')
def step_impl(context, rule):
assert context.profile_key != "", "PROFILE KEY NOT FOUND: %s" % str(context.profile_key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ Feature: Providing test execution numbers
Test if plugin is able to handle this.

GIVEN the project "boosttest_project"
and platform is not "Windows"

WHEN I run "sonar-runner -X -Dsonar.cxx.xunit.reportPath=btest_test_nested-test_suite.xml -Dsonar.cxx.xunit.provideDetails=true -Dsonar.cxx.includeDirectories=/usr/include"
THEN the analysis finishes successfully
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ sonar.projectName=ProjectX_CPP
sonar.projectVersion=1
sonar.projectDescription=
sonar.modules=A,B
sonar.cxx.cppcheck.reportPath=/home/travis/build/SonarOpenCommunity/sonar-cxx/integration-tests/testdata/cpp-multimodule-project-2-reports/reports-cppcheck/*.xml
sonar.cxx.cppcheck.reportPath=${TestDataFolder}/cpp-multimodule-project-2-reports/reports-cppcheck/*.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ sonar.host.url=http://localhost:9000

sonar.modules=cli,lib,package1,package2

cli.sonar.projectBaseDir=/home/travis/build/SonarOpenCommunity/sonar-cxx/integration-tests/testdata/cpp-multimodule-project/
cli.sonar.projectBaseDir=.
cli.sonar.sources=cli
cli.sonar.projectName=cli
cli.sonar.cxx.includeDirectories=../../googletest_project/tests/gtest-1.6.0/include/gtest

lib.sonar.projectBaseDir=/home/travis/build/SonarOpenCommunity/sonar-cxx/integration-tests/testdata/cpp-multimodule-project/
lib.sonar.projectBaseDir=.
lib.sonar.sources=lib
lib.sonar.projectName=lib

package1.sonar.projectBaseDir=/home/travis/build/SonarOpenCommunity/sonar-cxx/integration-tests/testdata/cpp-multimodule-project/
package1.sonar.projectBaseDir=.
package1.sonar.sources=package1
package1.sonar.projectName=package1

package2.sonar.projectBaseDir=/home/travis/build/SonarOpenCommunity/sonar-cxx/integration-tests/testdata/cpp-multimodule-project/
package2.sonar.projectBaseDir=.
package2.sonar.sources=package2
package2.sonar.projectName=package2

Expand Down

0 comments on commit c02e00b

Please sign in to comment.