Skip to content

Commit

Permalink
Integration Tests ruling build on travis.
Browse files Browse the repository at this point in the history
  • Loading branch information
lindamartin committed Sep 1, 2015
1 parent 119958b commit 9a77e79
Show file tree
Hide file tree
Showing 98 changed files with 112,308 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "its/sources"]
path = its/sources
url = git@github.com:SonarCommunity/php-test-sources.git
url = https://github.com/SonarCommunity/php-test-sources.git
13 changes: 10 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ jdk:
install: true
script: ./travis.sh
env:
- TESTS=CI
- TESTS=IT-DEV
- TESTS=IT-LTS
- TEST=ci

- TEST=ruling
SQ_VERSION=LATEST_RELEASE

- TEST=plugin
SQ_VERSION=DEV

- TEST=plugin
SQ_VERSION=LTS_OR_OLDEST_COMPATIBLE

matrix:
fast_finish: true
Expand Down
36 changes: 36 additions & 0 deletions its/ruling/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.sonarsource.parent</groupId>
<artifactId>parent</artifactId>
<version>28</version>
<relativePath/>
</parent>

<artifactId>it-php-ruling</artifactId>

<name>PHP :: Integration Tests :: Ruling</name>
<inceptionYear>2014</inceptionYear>

<dependencies>
<dependency>
<groupId>com.sonarsource.orchestrator</groupId>
<artifactId>sonar-orchestrator</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<version>1.4</version>
</dependency>
</dependencies>

</project>
61 changes: 61 additions & 0 deletions its/ruling/src/test/java/org/sonar/php/it/PHPRulingTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (C) 2014 SonarSource SA
* All rights reserved
* mailto:contact AT sonarsource DOT com
*/
package org.sonar.php.it;

import com.google.common.io.Files;
import com.sonar.orchestrator.Orchestrator;
import com.sonar.orchestrator.build.SonarRunner;
import com.sonar.orchestrator.locator.FileLocation;
import org.junit.ClassRule;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.nio.charset.StandardCharsets;

import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assert.assertTrue;

public class PHPRulingTest {

private static final String PLUGIN_KEY = "php";
private static final File LITS_DIFFERENCES_FILE = FileLocation.of("target/differences").getFile();

@ClassRule
public static Orchestrator ORCHESTRATOR = Orchestrator.builderEnv()
.addPlugin(PLUGIN_KEY)
.setMainPluginKey(PLUGIN_KEY)
.setOrchestratorProperty("litsVersion", "0.5")
.addPlugin("lits")
.restoreProfileAtStartup(FileLocation.of("src/test/resources/profile.xml"))
.build();

@Test
public void test() throws Exception {
assertTrue(
"SonarQube 5.1 is the minimum version to generate the issues report, change your orchestrator.properties",
ORCHESTRATOR.getConfiguration().getSonarVersion().isGreaterThanOrEquals("5.1"));
SonarRunner build = SonarRunner.create(FileLocation.of("../sources/src").getFile())
.setProjectKey("project")
.setProjectName("project")
.setProjectVersion("1")
.setSourceDirs(".")
.setSourceEncoding("UTF-8")
.setProfile("rules")
.setProperty("sonar.analysis.mode", "preview")
.setProperty("sonar.issuesReport.html.enable", "true")
.setProperty("dump.old", FileLocation.of("src/test/resources/expected").getFile().getAbsolutePath())
.setProperty("dump.new", FileLocation.of("target/actual").getFile().getAbsolutePath())
.setProperty("sonar.cpd.skip", "true")
.setProperty("lits.differences", LITS_DIFFERENCES_FILE.getAbsolutePath())
.setEnvironmentVariable("SONAR_RUNNER_OPTS", "-Xmx1000m");
ORCHESTRATOR.executeBuild(build);

assertThat(Files.toString(LITS_DIFFERENCES_FILE, StandardCharsets.UTF_8)).isEmpty();
}

}
Loading

0 comments on commit 9a77e79

Please sign in to comment.