Skip to content

Commit

Permalink
Upgrade melange 01 2018 (#48)
Browse files Browse the repository at this point in the history
Update to latest melange and fix test suites

* [Releng] Change Melange update site to 2018-01-19 build
* use new location of nebula update site
* update fsm sample with latest melange
* wipeout workspace befor building
* try to get more log on test failure
* makes manifest changer more robust

contributes to
eclipse-gemoc/gemoc-studio-modeldebugging#25 and
diverse-project/melange#105

* studio in using oxygen.2
* improve jenkins file

- keep only one artefact per branch*
- set periodic pipeline check

* tee stdout and stderr to for the standard output and  to console

see #49

* add helper.setTargetPlatform in test that fail randomly
* add launch conf in order to ease test devs
* disable concurrent builds
  • Loading branch information
dvojtise authored Feb 17, 2018
1 parent 802db35 commit 86a8045
Show file tree
Hide file tree
Showing 30 changed files with 275 additions and 180 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ build.acceleo
*._trace
**/gemoc-gen/*
**/xtend-gen/*
node_modules
/package-lock.json
13 changes: 8 additions & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!groovy
node {
properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10']]]);
properties([disableConcurrentBuilds(), [$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false], buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '1', daysToKeepStr: '', numToKeepStr: '10')), pipelineTriggers([[$class: 'PeriodicFolderTrigger', interval: '15m']])])

catchError {
def mvnHome
stage('Preparation') {

// Get code from GitHub repositories
// Wipe the workspace so we are building completely clean
deleteDir()

// Get code from GitHub repositories

// this will check if there is a branch with the same name as the current branch (ie. the branch containing this Jenkinsfile) and use that for the checkout, but if there is no
// branch with the same name it will fall back to the master branch
Expand Down Expand Up @@ -43,9 +46,9 @@ node {
}
}
stage('Deployment') {
junit '**/target/surefire-reports/TEST-*.xml'
junit keepLongStdio: true, testResults: '**/target/surefire-reports/TEST-*.xml'
archiveArtifacts '**/target/products/*.zip,**/gemoc-studio/gemoc_studio/releng/org.eclipse.gemoc.gemoc_studio.updatesite/target/repository/**'
}
}
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: '', sendToIndividuals: true])
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: '[email protected]', sendToIndividuals: true])
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import java.io.PrintStream;

import org.eclipse.gemoc.commons.eclipse.messagingsystem.ui.helper.TeeOutputStream;
import org.eclipse.gemoc.commons.eclipse.messagingsystem.ui.internal.EclipseConsoleOutputStream;
import org.eclipse.gemoc.commons.eclipse.messagingsystem.ui.internal.console.ConsoleIO;
import org.eclipse.gemoc.commons.eclipse.messagingsystem.ui.internal.console.EclipseConsoleIO;
Expand Down Expand Up @@ -106,26 +107,28 @@ public ConsoleIO getConsoleIO() {
return consoleIO;
}

protected PrintStream OriginalSystemOut = null;
protected PrintStream OriginalSystemErr = null;
protected PrintStream originalSystemOut = null;
protected PrintStream originalSystemErr = null;

/**
* set the current System.out and System.err so they are redirected to our
* default console
*/
public void captureSystemOutAndErr() {
Activator.getDefault().getConsoleIO().print("Redirecting System.out and System.err to this console.\n");
if (OriginalSystemOut != System.out) {
OriginalSystemOut = System.out;
PrintStream outPrintStream = new PrintStream(
if (originalSystemOut != System.out) {
originalSystemOut = System.out;
TeeOutputStream teeOutputStream = new TeeOutputStream(
originalSystemOut,
new EclipseConsoleOutputStream(Activator.getDefault().getConsoleIO(), false));
System.setOut(outPrintStream);
System.setOut(new PrintStream(teeOutputStream));
}
if (OriginalSystemErr != System.err) {
OriginalSystemOut = System.out;
PrintStream errPrintStream = new PrintStream(
if (originalSystemErr != System.err) {
originalSystemErr = System.err;
TeeOutputStream teeOutputStream = new TeeOutputStream(
originalSystemErr,
new EclipseConsoleOutputStream(Activator.getDefault().getConsoleIO(), true));
System.setErr(errPrintStream);
System.setErr(new PrintStream(teeOutputStream));
}
}

Expand All @@ -139,12 +142,12 @@ public void releaseSystemOutAndErr() {
System.err.flush();
if(consoleIO != null)
consoleIO.print("Stopping redirection of System.out and System.err to this console.\n");
if (OriginalSystemOut != null)
System.setOut(OriginalSystemOut);
if (OriginalSystemErr != null)
System.setErr(OriginalSystemErr);
OriginalSystemOut = null;
OriginalSystemErr = null;
if (originalSystemOut != null)
System.setOut(originalSystemOut);
if (originalSystemErr != null)
System.setErr(originalSystemErr);
originalSystemOut = null;
originalSystemErr = null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*******************************************************************************
* Copyright (c) 2018 Inria and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Inria - initial API and implementation
*******************************************************************************/
package org.eclipse.gemoc.commons.eclipse.messagingsystem.ui.helper;

import java.io.IOException;
import java.io.OutputStream;

public final class TeeOutputStream extends OutputStream {

private final OutputStream out;
private final OutputStream tee;

public TeeOutputStream(OutputStream out, OutputStream tee) {
if (out == null)
throw new NullPointerException();
else if (tee == null)
throw new NullPointerException();

this.out = out;
this.tee = tee;
}

@Override
public void write(int b) throws IOException {
out.write(b);
tee.write(b);
}

@Override
public void write(byte[] b) throws IOException {
out.write(b);
tee.write(b);
}

@Override
public void write(byte[] b, int off, int len) throws IOException {
out.write(b, off, len);
tee.write(b, off, len);
}

@Override
public void flush() throws IOException {
out.flush();
tee.flush();
}

@Override
public void close() throws IOException {
out.close();
tee.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.Map.Entry;
import java.util.jar.Attributes.Name;
import java.util.jar.Manifest;
Expand Down Expand Up @@ -107,7 +110,24 @@ private void writeManifest(IFile outputFile) throws IOException, CoreException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
writeManifest(out);
ByteArrayInputStream is = new ByteArrayInputStream(out.toByteArray());
outputFile.setContents(is, 1, new NullProgressMonitor());

try{
if (outputFile.exists()) {
if(!isStreamEqual(is, outputFile.getContents(true))){
// use a new stream because isStreamEqual has used and closed the previous one
outputFile.setContents(new ByteArrayInputStream(out.toByteArray()), true, true, new NullProgressMonitor());
}
} else {
outputFile.create(is, true, new NullProgressMonitor());
}
}
finally{
try {
if (out != null) out.close();
} catch(IOException e) {
//closing quielty
}
}
}
}
public void addPluginDependency(String plugin) throws BundleException, IOException, CoreException {
Expand All @@ -131,4 +151,38 @@ public void addSingleton() throws BundleException, IOException, CoreException {
public void addAttributes(String attributeName, String value){
_manifest.getMainAttributes().putValue(attributeName, value);
}

private static boolean isStreamEqual(InputStream i1, InputStream i2)
throws IOException {

ReadableByteChannel ch1 = Channels.newChannel(i1);
ReadableByteChannel ch2 = Channels.newChannel(i2);

ByteBuffer buf1 = ByteBuffer.allocateDirect(1024);
ByteBuffer buf2 = ByteBuffer.allocateDirect(1024);

try {
while (true) {

int n1 = ch1.read(buf1);
int n2 = ch2.read(buf2);

if (n1 == -1 || n2 == -1) return n1 == n2;

buf1.flip();
buf2.flip();

for (int i = 0; i < Math.min(n1, n2); i++)
if (buf1.get() != buf2.get())
return false;

buf1.compact();
buf2.compact();
}

} finally {
if (i1 != null) i1.close();
if (i2 != null) i2.close();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</parent>

<properties>
<eclipse.version.name>Oxygen.1A</eclipse.version.name>
<eclipse.version.name>Oxygen.2</eclipse.version.name>
<!-- override these values using -D option on the maven command line on the CI (see jenkinsfile for CI configuration)-->
<studio.variant>Local build</studio.variant>
<branch.variant>Unknown</branch.variant>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench">
<booleanAttribute key="append.args" value="true"/>
<booleanAttribute key="askclear" value="true"/>
<booleanAttribute key="automaticAdd" value="true"/>
<booleanAttribute key="automaticValidate" value="true"/>
<stringAttribute key="bootstrap" value=""/>
<stringAttribute key="checked" value="[NONE]"/>
<booleanAttribute key="clearConfig" value="false"/>
<booleanAttribute key="clearws" value="false"/>
<booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/open-junit-eclipse-test-worskpace"/>
<booleanAttribute key="default" value="true"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
<booleanAttribute key="show_selected_only" value="false"/>
<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
<booleanAttribute key="useDefaultConfig" value="true"/>
<booleanAttribute key="useDefaultConfigArea" value="true"/>
<booleanAttribute key="useProduct" value="true"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
<booleanAttribute key="append.args" value="true"/>
<booleanAttribute key="askclear" value="false"/>
<booleanAttribute key="automaticAdd" value="true"/>
<booleanAttribute key="automaticValidate" value="true"/>
<stringAttribute key="bootstrap" value=""/>
<stringAttribute key="checked" value="[NONE]"/>
<booleanAttribute key="clearConfig" value="true"/>
<booleanAttribute key="clearws" value="true"/>
<booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
<booleanAttribute key="default" value="true"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/org.eclipse.gemoc.studio.tests.system/xtend-gen/org/eclipse/gemoc/studio/tests/system/lwb/userstory/CreateSingleSequentialLanguageFromOfficialFSM_Test.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE" value="${workspace_loc:/org.eclipse.gemoc.studio.tests.system/console.output}"/>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-8-oracle"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.gemoc.studio.tests.system.lwb.userstory.CreateSingleSequentialLanguageFromOfficialFSM_Test"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.gemoc.studio.tests.system"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
<booleanAttribute key="run_in_ui_thread" value="false"/>
<booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="true"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
<booleanAttribute key="useDefaultConfig" value="true"/>
<booleanAttribute key="useDefaultConfigArea" value="false"/>
<booleanAttribute key="useProduct" value="true"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import org.eclipse.core.resources.IProject
import org.eclipse.xtext.junit4.AbstractXtextTests
import org.eclipse.xtext.junit4.InjectWith
import org.eclipse.xtext.junit4.XtextRunner
import org.eclipse.xtext.junit4.ui.util.IResourcesSetupUtil
import org.junit.After
import org.junit.Before
import org.junit.FixMethodOrder
Expand All @@ -33,6 +32,7 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem
import com.google.inject.Injector
import java.util.ArrayList
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences
import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil

/**
* Checks that the provided official sample can compile without error
Expand Down Expand Up @@ -70,6 +70,7 @@ public class GenerateLangRuntime4OfficialSampleLegacyFSM_Test extends AbstractXt
super.setUp
helper.init
IResourcesSetupUtil::cleanWorkspace
IResourcesSetupUtil::reallyWaitForAutoBuild

// try to respect build order in order to ease compilation, this will speed up the test
helper.deployProject(PROJECT_NAME+".model",BASE_FOLDER_NAME+"/"+PROJECT_NAME+".model.zip")
Expand All @@ -84,9 +85,12 @@ public class GenerateLangRuntime4OfficialSampleLegacyFSM_Test extends AbstractXt
//helper.deployProject(PROJECT_NAME2+".design",BASE_FOLDER_NAME+"/"+PROJECT_NAME2+".design.zip")

IResourcesSetupUtil::reallyWaitForAutoBuild
WorkspaceTestHelper::reallyWaitForJobs(4)
melangeHelper.cleanAll(MELANGE_FILE)
melangeHelper.cleanAll(MELANGE_FILE2)
IResourcesSetupUtil::fullBuild
IResourcesSetupUtil::reallyWaitForAutoBuild
WorkspaceTestHelper::reallyWaitForJobs(4)

val ArrayList<Throwable> thrownException = newArrayList()
Display.^default.syncExec([
Expand Down
Loading

0 comments on commit 86a8045

Please sign in to comment.