scripting: Use scripts from github instead of examples

Change-Id: Ia542a0295cdc16a62785cd08ab871f817fa8b109
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/150154
Tested-by: CI Bot
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
diff --git a/analyses/org.eclipse.tracecompass.incubator.scripting.ui.tests/pom.xml b/analyses/org.eclipse.tracecompass.incubator.scripting.ui.tests/pom.xml
new file mode 100644
index 0000000..5be19cd
--- /dev/null
+++ b/analyses/org.eclipse.tracecompass.incubator.scripting.ui.tests/pom.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Copyright (c) 2019 École Polytechnique de Montréal
+
+   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
+-->
+
+<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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <artifactId>org.eclipse.tracecompass.incubator.analyses-parent</artifactId>
+    <groupId>org.eclipse.tracecompass.incubator</groupId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <name>Trace Compass Incubator Scripting UI Tests Plug-in</name>
+  <artifactId>org.eclipse.tracecompass.incubator.scripting.ui.tests</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>eclipse-test-plugin</packaging>
+
+  <!-- Do not download the test traces if "maven.test.skip" is set -->
+  <profiles>
+    <profile>
+      <id>download-scripts</id>
+      <activation>
+        <property>
+          <name>!maven.test.skip</name>
+        </property>
+      </activation>
+
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>prepare</id>
+                <phase>pre-integration-test</phase>
+                <configuration>
+                  <target>
+                    <ant antfile="get-scripts.xml" dir="scripts" />
+                  </target>
+                </configuration>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+
+  <build>
+    <plugins>
+      <!-- We don't use the ant file to clean because of http://jira.codehaus.org/browse/MANTRUN-78 -->
+      <plugin>
+        <artifactId>maven-clean-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>clean-scripts</id>
+            <phase>clean</phase>
+            <configuration>
+              <filesets>
+                <fileset><directory>traces/tracecompass-ease-scripting</directory></fileset>
+              </filesets>
+            </configuration>
+            <goals>
+              <goal>clean</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/analyses/org.eclipse.tracecompass.incubator.scripting.ui.tests/scripts/get-scripts.xml b/analyses/org.eclipse.tracecompass.incubator.scripting.ui.tests/scripts/get-scripts.xml
new file mode 100644
index 0000000..bcacd71
--- /dev/null
+++ b/analyses/org.eclipse.tracecompass.incubator.scripting.ui.tests/scripts/get-scripts.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+   Copyright (c) 2019 École Polytechnique de Montréal
+
+   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
+-->
+
+<project name="Get Scripts" default="main" >
+<target name="main">
+  <exec executable = "git" failifexecutionfails="false" timeout="20000">
+    <arg value = "clone"/>
+    <arg value = "https://github.com/tahini/tracecompass-ease-scripting.git"/>
+  </exec>
+  <condition property="testSuiteExists">
+    <and>
+      <available file="tracecompass-ease-scripting" type="dir"/>
+    </and>
+  </condition>
+  <antcall target="pullTestSuite"/>
+</target>
+
+<target name="pullTestSuite" if="testSuiteExists">
+  <!-- Update the local 'master' branch -->
+  <exec executable = "git" failifexecutionfails="false" dir="tracecompass-ease-scripting" timeout="20000">
+    <arg value = "checkout"/>
+    <arg value = "master"/>
+  </exec>
+  <exec executable = "git" failifexecutionfails="false" dir="tracecompass-ease-scripting" timeout="20000">
+    <arg value = "pull"/>
+  </exec>
+</target>
+
+</project>
diff --git a/analyses/org.eclipse.tracecompass.incubator.scripting.ui.tests/src/org/eclipse/tracecompass/incubator/scripting/ui/tests/ScriptTest.java b/analyses/org.eclipse.tracecompass.incubator.scripting.ui.tests/src/org/eclipse/tracecompass/incubator/scripting/ui/tests/ScriptTest.java
index 681052d..b7e98ff 100644
--- a/analyses/org.eclipse.tracecompass.incubator.scripting.ui.tests/src/org/eclipse/tracecompass/incubator/scripting/ui/tests/ScriptTest.java
+++ b/analyses/org.eclipse.tracecompass.incubator.scripting.ui.tests/src/org/eclipse/tracecompass/incubator/scripting/ui/tests/ScriptTest.java
@@ -9,12 +9,12 @@
 
 package org.eclipse.tracecompass.incubator.scripting.ui.tests;
 
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.net.URL;
 import java.nio.charset.Charset;
 import java.nio.file.FileVisitResult;
 import java.nio.file.Files;
@@ -34,7 +34,6 @@
 import org.eclipse.core.resources.IWorkspaceRoot;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.ease.IExecutionListener;
@@ -45,8 +44,6 @@
 import org.eclipse.ease.service.ScriptService;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.common.core.TraceCompassActivator;
-import org.eclipse.tracecompass.incubator.internal.scripting.core.Activator;
 import org.eclipse.tracecompass.incubator.scripting.core.tests.stubs.ScriptingTestUtils;
 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
@@ -83,7 +80,7 @@
     private static final @NonNull String SOME_PROJECT_NAME = "myProject";
     private static final @NonNull IProgressMonitor PROGRESS_MONITOR = new NullProgressMonitor();
 
-    private static final String DOC_FOLDER = "src/org/eclipse/tracecompass/incubator/scripting/core/doc-files";
+    private static final String SCRIPT_FOLDER = "scripts/tracecompass-ease-scripting/";
 
     // Final fields for the test
     private final IScriptEngine fScriptEngine;
@@ -118,6 +115,7 @@
             }
 
             List<Path> filesForEngine = getFilesForEngine(engineDescription);
+            assertFalse(filesForEngine.isEmpty());
             for (Path file : filesForEngine) {
                 /*
                  * A separate engine needs to be created for each script,
@@ -202,9 +200,7 @@
         List<Path> files = new ArrayList<>();
 
         // Get the files from the scripting core plugin's documentation folder
-        TraceCompassActivator corePlugin = Activator.getInstance();
-        URL location = FileLocator.find(corePlugin.getBundle(), new org.eclipse.core.runtime.Path(DOC_FOLDER), null);
-        org.eclipse.core.runtime.Path path = new org.eclipse.core.runtime.Path(FileLocator.toFileURL(location).getPath());
+        org.eclipse.core.runtime.IPath path = ActivatorTest.getAbsoluteFilePath(SCRIPT_FOLDER);
         Files.walkFileTree(Paths.get(path.toOSString()), new SimpleFileVisitor<Path>() {
             @Override
             public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {