Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated unit tests to succeed again. Added master test suite.

Updated EasyMock to give us the resetToDefault() function.
Made some changes to GhcCompiler for the benefit of the unit tests.
  • Loading branch information...
commit b0128ed5cc3e8a5a75a258ee25431192270133ac 1 parent 1508a2f
@ttencate ttencate authored
Showing with 371 additions and 154 deletions.
  1. +0 −18 net.sf.eclipsefp.haskell.core.jparser.test/src/net/sf/eclipsefp/haskell/core/jparser/test/AllAllTests.java
  2. +3 −4 ...f.eclipsefp.haskell.core.jparser.test/src/net/sf/eclipsefp/haskell/core/jparser/test/AllTests_PDESuite.java
  3. +3 −4 ....test/src/net/sf/eclipsefp/haskell/core/jparser/test/{AllAllTests_PDESuite.java → AllTests_Suite.java}
  4. +2 −3 ...kell.core.jparser.test/src/net/sf/eclipsefp/haskell/core/jparser/test/{AllTests.java → MainTests.java}
  5. +17 −0 ....eclipsefp.haskell.core.jparser.test/src/net/sf/eclipsefp/haskell/core/jparser/test/MainTests_PDESuite.java
  6. +25 −11 ...sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/halamo/WorkspaceChangeMonitor_PDETest.java
  7. +2 −2 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/test/TestCaseWithProject.java
  8. +43 −42 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/util/ProcessRunner_Test.java
  9. +10 −5 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/util/IProcessRunner.java
  10. +16 −22 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/util/ProcessRunner.java
  11. +1 −1  ...ui.test/INTERNAL/java/test/net/sf/eclipsefp/haskell/debug/ui/test/{internal → }/AllTests_PDESuite.java
  12. +1 −0  net.sf.eclipsefp.haskell.debug.ui.test/META-INF/MANIFEST.MF
  13. +1 −0  net.sf.eclipsefp.haskell.ghccompiler.test/META-INF/MANIFEST.MF
  14. +41 −7 ...fp.haskell.ghccompiler.test/src/net/sf/eclipsefp/haskell/ghccompiler/test/core/GhcCompilerTest_PDETest.java
  15. +10 −6 net.sf.eclipsefp.haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/core/GhcCompiler.java
  16. +7 −3 net.sf.eclipsefp.haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/core/GhcOutputProcessor.java
  17. +15 −0 net.sf.eclipsefp.haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/core/IGhcOutputProcessor.java
  18. +12 −0 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/types/Location.java
  19. +13 −0 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/types/Note.java
  20. +13 −0 net.sf.eclipsefp.haskell.test/.classpath
  21. +1 −0  net.sf.eclipsefp.haskell.test/.gitignore
  22. +28 −0 net.sf.eclipsefp.haskell.test/.project
  23. +8 −0 net.sf.eclipsefp.haskell.test/.settings/org.eclipse.jdt.core.prefs
  24. +14 −0 net.sf.eclipsefp.haskell.test/META-INF/MANIFEST.MF
  25. +4 −0 net.sf.eclipsefp.haskell.test/build.properties
  26. +19 −0 net.sf.eclipsefp.haskell.test/src/net/sf/eclipsefp/test/AllTests_PDESuite.java
  27. +17 −0 net.sf.eclipsefp.haskell.test/src/net/sf/eclipsefp/test/AllTests_Suite.java
  28. +26 −15 net.sf.eclipsefp.haskell.ui.test/.settings/org.eclipse.pde.prefs
  29. +19 −11 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/scion/ScionManager.java
  30. BIN  org.easymock/lib/easymock.jar
View
18 net.sf.eclipsefp.haskell.core.jparser.test/src/net/sf/eclipsefp/haskell/core/jparser/test/AllAllTests.java
@@ -1,18 +0,0 @@
-package net.sf.eclipsefp.haskell.core.jparser.test;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllAllTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(
- "Test for net.sf.eclipsefp.haskell.core.jparser.test");
- //$JUnit-BEGIN$
- suite.addTest(net.sf.eclipsefp.haskell.core.jparser.test.AllTests.suite());
- suite.addTest(net.sf.eclipsefp.haskell.core.jparser.ast.test.AllTests.suite());
- //$JUnit-END$
- return suite;
- }
-
-}
View
7 ...clipsefp.haskell.core.jparser.test/src/net/sf/eclipsefp/haskell/core/jparser/test/AllTests_PDESuite.java
@@ -6,11 +6,10 @@
public class AllTests_PDESuite {
public static Test suite() {
- TestSuite suite = new TestSuite(
- "Test for net.sf.eclipsefp.haskell.core.jparser.test");
+ TestSuite suite = new TestSuite();
//$JUnit-BEGIN$
- suite.addTestSuite(ParserPlugin_PDETest.class);
- suite.addTest(AllTests.suite());
+ suite.addTest(net.sf.eclipsefp.haskell.core.jparser.test.MainTests_PDESuite.suite());
+ suite.addTest(net.sf.eclipsefp.haskell.core.jparser.ast.test.AllTests.suite());
//$JUnit-END$
return suite;
}
View
7 ...skell/core/jparser/test/AllAllTests_PDESuite.java → ...efp/haskell/core/jparser/test/AllTests_Suite.java
@@ -3,13 +3,12 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-public class AllAllTests_PDESuite {
+public class AllTests_Suite {
public static Test suite() {
- TestSuite suite = new TestSuite(
- "JParser plugin full test suit");
+ TestSuite suite = new TestSuite();
//$JUnit-BEGIN$
- suite.addTest(net.sf.eclipsefp.haskell.core.jparser.test.AllTests_PDESuite.suite());
+ suite.addTest(net.sf.eclipsefp.haskell.core.jparser.test.MainTests.suite());
suite.addTest(net.sf.eclipsefp.haskell.core.jparser.ast.test.AllTests.suite());
//$JUnit-END$
return suite;
View
5 ...eclipsefp/haskell/core/jparser/test/AllTests.java → ...clipsefp/haskell/core/jparser/test/MainTests.java
@@ -3,11 +3,10 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-public class AllTests {
+public class MainTests {
public static Test suite() {
- TestSuite suite = new TestSuite(
- "Test for net.sf.eclipsefp.haskell.core.jparser.test");
+ TestSuite suite = new TestSuite();
//$JUnit-BEGIN$
suite.addTestSuite(ParserIntegrationTest.class);
suite.addTestSuite(LexerTest.class);
View
17 ...lipsefp.haskell.core.jparser.test/src/net/sf/eclipsefp/haskell/core/jparser/test/MainTests_PDESuite.java
@@ -0,0 +1,17 @@
+package net.sf.eclipsefp.haskell.core.jparser.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class MainTests_PDESuite {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ //$JUnit-BEGIN$
+ suite.addTestSuite(ParserPlugin_PDETest.class);
+ suite.addTest(MainTests.suite());
+ //$JUnit-END$
+ return suite;
+ }
+
+}
View
36 ...eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/halamo/WorkspaceChangeMonitor_PDETest.java
@@ -1,10 +1,12 @@
package net.sf.eclipsefp.haskell.core.halamo;
import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.checkOrder;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.resetToDefault;
import static org.easymock.EasyMock.verify;
import junit.framework.TestCase;
import net.sf.eclipsefp.haskell.core.internal.util.TestHaskellProject;
@@ -23,15 +25,15 @@
public void testCreatesChangeMonitorWhenProjectIsCreated()
throws CoreException
{
- expect(getFactory().createProjectChangeMonitor((IProject) anyObject())).
- andReturn(null).
- atLeastOnce();
- replay(getFactory());
+ IProjectChangeMonitorFactory factory = getFactory();
+ expect(factory.createProjectChangeMonitor((IProject) anyObject())).
+ andReturn( createMock(IResourceChangeListener.class) );
+ replay(factory);
- TestHaskellProject prj = new TestHaskellProject("testing-project");
+ TestHaskellProject prj = new TestHaskellProject("createsChangeMonitorProject");
prj.destroy();
- verify(getFactory());
+ verify(factory);
}
public void testDelegatesProjectEventsToCorrespondingMonitor() throws CoreException {
@@ -43,7 +45,7 @@ public void testDelegatesProjectEventsToCorrespondingMonitor() throws CoreExcept
andReturn(sndMonitor);
replay(getFactory());
- TestHaskellProject fstPrj = new TestHaskellProject("fisrt-project");
+ TestHaskellProject fstPrj = new TestHaskellProject("first-project");
TestHaskellProject sndPrj = new TestHaskellProject("second-project");
try {
@@ -64,8 +66,12 @@ public void testCreatesProjectMonitorsForLoadedWorkspace()
IProjectChangeMonitorFactory factory =
createMock(IProjectChangeMonitorFactory.class);
- expect(factory.createProjectChangeMonitor(prj.getPlatformProject())).
- andReturn(createNiceMock(IResourceChangeListener.class));
+ expect(factory.createProjectChangeMonitor(prj.getPlatformProject()))
+ .andReturn(createNiceMock(IResourceChangeListener.class));
+ expect(factory.createProjectChangeMonitor( (IProject ) anyObject() ))
+ .andReturn( createNiceMock(IResourceChangeListener.class) )
+ .atLeastOnce(); // projects might already exist in the workspace
+ checkOrder(factory, false);
replay(factory);
WorkspaceChangeMonitor mon = new WorkspaceChangeMonitor(factory);
@@ -84,9 +90,17 @@ private IWorkspace getWorkspace() {
private IProjectChangeMonitorFactory getFactory() {
if (fFactory == null) {
- fFactory = createNiceMock(IProjectChangeMonitorFactory.class);
- fMonitor = new WorkspaceChangeMonitor(getFactory());
+ // WorkspaceChangeMonitor.observeChangesOn() will cause some calls on IProjectChangeMonitorFactory
+ // and expects it to return non-null
+ fFactory = createMock(IProjectChangeMonitorFactory.class);
+ expect(fFactory.createProjectChangeMonitor( (IProject ) anyObject() ))
+ .andStubReturn( createNiceMock(IResourceChangeListener.class) );
+ replay(fFactory);
+
+ fMonitor = new WorkspaceChangeMonitor(fFactory);
fMonitor.observeChangesOn(getWorkspace());
+
+ resetToDefault(fFactory);
}
return fFactory;
}
View
4 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/test/TestCaseWithProject.java
@@ -29,7 +29,7 @@
public static void waitForAutoBuild() throws CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.build( IncrementalProjectBuilder.CLEAN_BUILD, null );
- System.out.print( " Waiting for autobuild to complete ..." ); //$NON-NLS-1$
+ // System.out.print( " Waiting for autobuild to complete ..." ); //$NON-NLS-1$
IJobManager jobMan = Job.getJobManager();
boolean retry = true;
while( retry ) {
@@ -42,7 +42,7 @@ public static void waitForAutoBuild() throws CoreException {
// ignore and retry
}
}
- System.out.print( " OK.\n" ); //$NON-NLS-1$
+ // System.out.print( " OK.\n" ); //$NON-NLS-1$
}
View
85 net.sf.eclipsefp.haskell.core.test/src/net/sf/eclipsefp/haskell/core/util/ProcessRunner_Test.java
@@ -12,47 +12,48 @@
public class ProcessRunner_Test extends TestCase {
- public void testReturnsStandardOutput() throws IOException {
- final String expectedResult = "standard output contents";
- IProcessFactory factory = createProcessFactory(expectedResult, "");
-
- ProcessRunner runner = new ProcessRunner(factory);
- String actualResult = runner.executeBlocking(new File("unimportant"),
- new NullWriter(),
- "unimportant");
- assertEquals(expectedResult, actualResult);
- }
-
- public void testReturnsStandardError() throws IOException {
- final String expectedResult = "standard error stream contents\n";
- IProcessFactory factory = createProcessFactory("", expectedResult);
-
- ProcessRunner runner = new ProcessRunner(factory);
- String actualResult = runner.executeBlocking(new File("unimportant"),
- new NullWriter(),
- "unimportant");
- assertEquals(expectedResult, actualResult);
- }
-
- public void testMergesOutputStreams() throws IOException {
- final String expectedOut = "standard output stream contents\n";
- final String expectedErr = "standard error stream contents\n";
- IProcessFactory factory = createProcessFactory(expectedOut, expectedErr);
-
- ProcessRunner runner = new ProcessRunner(factory);
- final StringWriter out = new StringWriter();
- runner.executeBlocking(new File("unimportant"), out, "unimportant");
-
- assertTrue(out.toString().contains(expectedOut));
- assertTrue(out.toString().contains(expectedErr));
- }
-
- private IProcessFactory createProcessFactory(final String stdout, final String stderr) throws IOException {
- IProcessFactory factory = createMock(IProcessFactory.class);
- expect(factory.startProcess((File) anyObject(), (String[]) anyObject()))
- .andReturn(new StubProcess(stdout, stderr));
- replay(factory);
- return factory;
- }
+ public void testReturnsStandardOutput() throws IOException {
+ final String expectedResult = "standard output contents";
+ IProcessFactory factory = createProcessFactory( expectedResult, "" );
+
+ ProcessRunner runner = new ProcessRunner( factory );
+ StringWriter actualResult = new StringWriter();
+ runner.executeBlocking( new File( "unimportant" ),
+ actualResult, new NullWriter(), "unimportant" );
+ assertEquals( expectedResult, actualResult.toString() );
+ }
+
+ public void testReturnsStandardError() throws IOException {
+ final String expectedResult = "standard error stream contents\n";
+ IProcessFactory factory = createProcessFactory( "", expectedResult );
+
+ ProcessRunner runner = new ProcessRunner( factory );
+ StringWriter actualResult = new StringWriter();
+ runner.executeBlocking( new File( "unimportant" ),
+ new NullWriter(), actualResult, "unimportant" );
+ assertEquals( expectedResult, actualResult.toString() );
+ }
+
+ public void testMergesOutputStreams() throws IOException {
+ final String expectedOut = "standard output stream contents\n";
+ final String expectedErr = "standard error stream contents\n";
+ IProcessFactory factory = createProcessFactory( expectedOut, expectedErr );
+
+ ProcessRunner runner = new ProcessRunner( factory );
+ final StringWriter actualResult = new StringWriter();
+ runner.executeBlocking( new File( "unimportant" ), actualResult, actualResult, "unimportant" );
+
+ assertTrue( actualResult.toString().contains( expectedOut ) );
+ assertTrue( actualResult.toString().contains( expectedErr ) );
+ }
+
+ private IProcessFactory createProcessFactory( final String stdout,
+ final String stderr ) throws IOException {
+ IProcessFactory factory = createMock( IProcessFactory.class );
+ expect( factory.startProcess( ( File )anyObject(), ( String[] )anyObject() ) )
+ .andReturn( new StubProcess( stdout, stderr ) );
+ replay( factory );
+ return factory;
+ }
}
View
15 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/util/IProcessRunner.java
@@ -14,6 +14,7 @@
import java.io.File;
import java.io.IOException;
import java.io.Writer;
+import net.sf.eclipsefp.haskell.core.compiler.NullWriter;
public interface IProcessRunner {
@@ -21,22 +22,26 @@
* Runs the program, and returns when it completes.
*
* @param workingDir the working directory from which the program should be started
- * @param out the {@link Writer} to receive the process's merged stdout/stderr streams
+ * @param out the {@link Writer} to receive the process's stdout stream (may be equal to err, but not null)
+ * @param err the {@link Writer} to receive the process's stderr stream (may be equal to out, but not null)
* @param args the command line
*
- * @returns all output generated on the program's stdout/stderr streams
+ * @see {@link NullWriter}
*/
- String executeBlocking(File workingDir, Writer out, String... args);
+ void executeBlocking(File workingDir, Writer out, Writer err, String... args) throws IOException;
/**
* Runs the program and returns immediately.
*
* @param workingDir the working directory from which the program should be started
- * @param outs the {@link Writer}s to receive the process's merged stdout/stderr streams
+ * @param out the {@link Writer} to receive the process's stdout stream (may be equal to err, but not null)
+ * @param err the {@link Writer} to receive the process's stderr stream (may be equal to out, but not null)
* @param args the command line
*
* @return the running process
+ *
+ * @see {@link NullWriter}
*/
- Process executeNonblocking(File workingDir, Writer out, String... args) throws IOException;
+ Process executeNonblocking(File workingDir, Writer out, Writer err, String... args) throws IOException;
}
View
38 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/util/ProcessRunner.java
@@ -4,11 +4,7 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
-import java.io.StringWriter;
import java.io.Writer;
-import java.util.ArrayList;
-import java.util.List;
-import net.sf.eclipsefp.haskell.core.internal.util.MultiplexedWriter;
import net.sf.eclipsefp.haskell.core.internal.util.StreamRedirect;
public class ProcessRunner implements IProcessRunner {
@@ -23,34 +19,32 @@ public ProcessRunner( final IProcessFactory factory ) {
fProcessFactory = factory;
}
- public String executeBlocking( final File workingDir, final Writer out,
- final String ... args ) {
- List<Exception> excList = new ArrayList<Exception>();
- StringWriter returnedOut = new StringWriter();
- try {
- Writer outs = new MultiplexedWriter(returnedOut, out);
- Process proc = doExecute( workingDir, args );
- Thread outRedirect = redirect( new InputStreamReader(proc.getInputStream()), outs );
+ public void executeBlocking( final File workingDir, final Writer out,
+ final Writer err, final String ... args ) throws IOException {
+
+ Process proc = doExecute( workingDir, args );
+ Thread outRedirect = redirect( new InputStreamReader( proc.getInputStream() ), out );
+ Thread errRedirect = redirect( new InputStreamReader( proc.getErrorStream() ), err );
+
+ try {
proc.waitFor(); // wait for process to finish
outRedirect.join(); // wait until out stream content is redirected
- } catch( Exception e ) {
- excList.add( e );
- } finally {
- returnedOut.flush();
+ errRedirect.join(); // wait until err stream content is redirected
+ } catch (InterruptedException ex) {
+ // ignore
}
-
- return returnedOut.toString();
}
- public Process executeNonblocking( final File workingDir,
- final Writer out, final String... args ) throws IOException {
+ public Process executeNonblocking( final File workingDir, final Writer out,
+ final Writer err, final String ... args ) throws IOException {
Process proc = doExecute( workingDir, args );
- redirect( new InputStreamReader(proc.getInputStream()), out );
+ redirect( new InputStreamReader( proc.getInputStream() ), out );
+ redirect( new InputStreamReader( proc.getErrorStream() ), err );
return proc;
}
- private Process doExecute( final File workingDir, final String... args )
+ private Process doExecute( final File workingDir, final String ... args )
throws IOException {
Process proc = fProcessFactory.startProcess( workingDir, args );
return proc;
View
2  ...ell/debug/ui/test/internal/AllTests_PDESuite.java → ...sefp/haskell/debug/ui/test/AllTests_PDESuite.java
@@ -1,7 +1,7 @@
// Copyright (c) 2003-2008 by Leif Frenzel. All rights reserved.
// This code is made available under the terms of the Eclipse Public License,
// version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
-package net.sf.eclipsefp.haskell.debug.ui.test.internal;
+package net.sf.eclipsefp.haskell.debug.ui.test;
import junit.framework.Test;
import junit.framework.TestSuite;
View
1  net.sf.eclipsefp.haskell.debug.ui.test/META-INF/MANIFEST.MF
@@ -15,3 +15,4 @@ Require-Bundle: net.sf.eclipsefp.haskell.core,
org.junit
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: net.sf.eclipsefp.haskell.debug.ui.test
View
1  net.sf.eclipsefp.haskell.ghccompiler.test/META-INF/MANIFEST.MF
@@ -13,3 +13,4 @@ Require-Bundle: org.easymock;bundle-version="[2.2.0,3.0.0)",
net.sf.eclipsefp.haskell.core.test
Export-Package: net.sf.eclipsefp.haskell.ghccompiler.test
Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Import-Package: net.sf.eclipsefp.haskell.scion.types
View
48 ...haskell.ghccompiler.test/src/net/sf/eclipsefp/haskell/ghccompiler/test/core/GhcCompilerTest_PDETest.java
@@ -12,29 +12,63 @@
package net.sf.eclipsefp.haskell.ghccompiler.test.core;
import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createStrictMock;
import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.getCurrentArguments;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import java.io.File;
+import java.io.IOException;
import java.io.Writer;
import net.sf.eclipsefp.haskell.core.compiler.IHaskellCompiler;
import net.sf.eclipsefp.haskell.core.internal.project.HaskellProject_PDETestCase;
import net.sf.eclipsefp.haskell.core.util.IProcessRunner;
import net.sf.eclipsefp.haskell.ghccompiler.core.GhcCompiler;
+import net.sf.eclipsefp.haskell.ghccompiler.core.IGhcOutputProcessor;
+import net.sf.eclipsefp.haskell.scion.types.Location;
+import net.sf.eclipsefp.haskell.scion.types.Note;
+import org.easymock.IAnswer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
public class GhcCompilerTest_PDETest extends HaskellProject_PDETestCase {
- public void testParseOneErrorResult() throws CoreException {
- IProcessRunner procRunner = createMock(IProcessRunner.class);
- expect(procRunner.executeBlocking((File) anyObject(), (Writer) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject()))
- .andReturn("\nMain.hs:1:25-27: Not in scope: `fat'\n");
+ class ExecuteAnswer implements IAnswer<Process> {
+ private final String output;
+ public ExecuteAnswer(final String output) {
+ this.output = output;
+ }
+ public Process answer() {
+ Writer out = (Writer)(getCurrentArguments()[1]);
+ try {
+ out.write( output );
+ out.close();
+ } catch( IOException e ) {
+ // ignore
+ }
+ return null;
+ }
+ }
+
+ public void testParseOneErrorResult() throws CoreException, IOException {
+ String fileName = "Main.hs";
+ String program = "main = putStrLn $ show $ fat 4";
+ String output = "[1 of 1] Compiling Main ( Main.hs, Main.o )\n\nMain.hs:1:25: Not in scope: `fat'\n";
+ Note note = new Note(Note.Kind.ERROR, new Location( fileName, 0, 25, 0, 25 ), "Not in scope: `fat'", "");
+
+ IProcessRunner procRunner = createStrictMock(IProcessRunner.class);
+ expect(procRunner.executeNonblocking((File) anyObject(), (Writer) anyObject(), (Writer) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject(), (String) anyObject()))
+ .andStubAnswer( new ExecuteAnswer(output) );
replay(procRunner);
- IFile f = createSourceFile("main = putStrLn $ show $ fat 4", "Main.hs");
- IHaskellCompiler compiler = new GhcCompiler(procRunner);
+ IGhcOutputProcessor outputProcessor = createStrictMock(IGhcOutputProcessor.class);
+ outputProcessor.setWorkingDir( (File)anyObject() );
+ outputProcessor.compiling( fileName, 1, 1 );
+ outputProcessor.message( note );
+ replay(outputProcessor);
+
+ IFile f = createSourceFile(program, fileName);
+ IHaskellCompiler compiler = new GhcCompiler(procRunner, outputProcessor);
compiler.compile(f);
verify(procRunner);
}
View
16 net.sf.eclipsefp.haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/core/GhcCompiler.java
@@ -38,14 +38,17 @@
private static boolean trace = GhcCompilerPlugin.isTracing();
private final IProcessRunner fProcessRunner;
+ private final IGhcOutputProcessor fOutputProcessor;
private final CompilerParams compilerParams = new CompilerParams();
public GhcCompiler() {
- this.fProcessRunner = new ProcessRunner();
+ fProcessRunner = new ProcessRunner();
+ fOutputProcessor = new GhcOutputProcessor( );
}
- public GhcCompiler(final IProcessRunner processRunner) {
- this.fProcessRunner = processRunner;
+ public GhcCompiler(final IProcessRunner processRunner, final IGhcOutputProcessor outputProcessor) {
+ fProcessRunner = processRunner;
+ fOutputProcessor = outputProcessor;
}
@Override
@@ -76,14 +79,15 @@ public void compile( final IFile file, final Writer outputWriter ) {
}
try {
- fProcessRunner.executeNonblocking( workDir, new MultiplexedWriter( outputWriter, pipedWriter ), cmdLine );
+ Writer out = new MultiplexedWriter( outputWriter, pipedWriter );
+ fProcessRunner.executeNonblocking( workDir, out, out, cmdLine );
} catch( IOException ex ) {
GhcCompilerPlugin.log( UITexts.error_launchGhc, ex );
return;
}
- GhcOutputProcessor outputProcessor = new GhcOutputProcessor( workDir );
- GhcOutputParser outputParser = new GhcOutputParser( pipedReader, outputProcessor );
+ fOutputProcessor.setWorkingDir( workDir );
+ GhcOutputParser outputParser = new GhcOutputParser( pipedReader, fOutputProcessor );
try {
outputParser.parse();
} catch( IOException ex ) {
View
10 net.sf.eclipsefp.haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/core/GhcOutputProcessor.java
@@ -19,11 +19,15 @@
*
* @author Thomas ten Cate
*/
-public class GhcOutputProcessor implements IGhcOutputListener {
+public class GhcOutputProcessor implements IGhcOutputProcessor {
- private final File workingDir;
+ private File workingDir;
- public GhcOutputProcessor(final File workingDir) {
+ public GhcOutputProcessor() {
+ this.workingDir = new File(""); //$NON-NLS-1$
+ }
+
+ public void setWorkingDir(final File workingDir) {
this.workingDir = workingDir;
}
View
15 net.sf.eclipsefp.haskell.ghccompiler/src/net/sf/eclipsefp/haskell/ghccompiler/core/IGhcOutputProcessor.java
@@ -0,0 +1,15 @@
+package net.sf.eclipsefp.haskell.ghccompiler.core;
+
+import java.io.File;
+
+/**
+ * A listener that processes the GHC output in some way.
+ * Instances must be reusable for multiple compilation sessions.
+ *
+ * @author Thomas ten Cate
+ */
+public interface IGhcOutputProcessor extends IGhcOutputListener {
+
+ public abstract void setWorkingDir( File file );
+
+}
View
12 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/types/Location.java
@@ -88,6 +88,18 @@ public int getEndColumn() {
}
@Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof Location)) {
+ return false;
+ }
+ Location other = (Location)obj;
+ return
+ fileName.equals(other.fileName) &&
+ startLine == other.startLine && startColumn == other.startColumn &&
+ endLine == other.endLine && endColumn == other.endColumn;
+ }
+
+ @Override
public String toString() {
return String.format("%d:%d-%d:%d", startLine, startColumn, endLine, endColumn);
}
View
13 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/types/Note.java
@@ -75,6 +75,19 @@ public void applyAsMarker(IResource resource) throws CoreException {
}
@Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof Note)) {
+ return false;
+ }
+ Note other = (Note)obj;
+ return
+ kind.equals(other.kind) &&
+ location.equals(other.location) &&
+ message.equals(other.message) &&
+ additionalInfo.equals(other.additionalInfo);
+ }
+
+ @Override
public String toString() {
return String.format("%s:%s: %s", kind.toString(), location.toString(), message);
}
View
13 net.sf.eclipsefp.haskell.test/.classpath
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/net.sf.eclipsefp.haskell.core.jparser.test"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/net.sf.eclipsefp.haskell.core.parser.test"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/net.sf.eclipsefp.haskell.core.test"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/net.sf.eclipsefp.haskell.debug.ui.test"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/net.sf.eclipsefp.haskell.ghccompiler.test"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/net.sf.eclipsefp.haskell.ui.test"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
View
1  net.sf.eclipsefp.haskell.test/.gitignore
@@ -0,0 +1 @@
+bin/
View
28 net.sf.eclipsefp.haskell.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>net.sf.eclipsefp.haskell.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
View
8 net.sf.eclipsefp.haskell.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Mon Jul 27 13:09:56 CEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
View
14 net.sf.eclipsefp.haskell.test/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Haskell Test Plug-In
+Bundle-SymbolicName: net.sf.eclipsefp.haskell.test
+Bundle-Version: 1.106.0
+Require-Bundle: net.sf.eclipsefp.haskell.core.test,
+ org.junit,
+ net.sf.eclipsefp.haskell.core.jparser.test;bundle-version="1.106.0",
+ net.sf.eclipsefp.haskell.core.parser.test;bundle-version="1.106.0",
+ net.sf.eclipsefp.haskell.debug.ui.test;bundle-version="1.106.0",
+ net.sf.eclipsefp.haskell.ghccompiler.test;bundle-version="1.106.0",
+ net.sf.eclipsefp.haskell.ui.test;bundle-version="1.106.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
View
4 net.sf.eclipsefp.haskell.test/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
View
19 net.sf.eclipsefp.haskell.test/src/net/sf/eclipsefp/test/AllTests_PDESuite.java
@@ -0,0 +1,19 @@
+package net.sf.eclipsefp.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests_PDESuite {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.addTest(net.sf.eclipsefp.haskell.core.test.AllTests_PDESuite.suite());
+ suite.addTest(net.sf.eclipsefp.haskell.core.jparser.test.AllTests_PDESuite.suite());
+ suite.addTest(net.sf.eclipsefp.haskell.core.parser.AllTests_PDESuite.suite());
+ suite.addTest(net.sf.eclipsefp.haskell.debug.ui.test.AllTests_PDESuite.suite());
+ suite.addTest(net.sf.eclipsefp.haskell.ghccompiler.test.AllTests_PDESuite.suite());
+ suite.addTest(net.sf.eclipsefp.haskell.ui.test.AllTests_PDESuite.suite());
+ return suite;
+ }
+
+}
View
17 net.sf.eclipsefp.haskell.test/src/net/sf/eclipsefp/test/AllTests_Suite.java
@@ -0,0 +1,17 @@
+package net.sf.eclipsefp.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests_Suite {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.addTest(net.sf.eclipsefp.haskell.core.test.AllTests_Suite.suite());
+ suite.addTest(net.sf.eclipsefp.haskell.core.jparser.test.AllTests_Suite.suite());
+ suite.addTest(net.sf.eclipsefp.haskell.ghccompiler.test.AllTests_Suite.suite());
+ suite.addTest(net.sf.eclipsefp.haskell.ui.test.AllTests_Suite.suite());
+ return suite;
+ }
+
+}
View
41 net.sf.eclipsefp.haskell.ui.test/.settings/org.eclipse.pde.prefs
@@ -1,15 +1,26 @@
-#Sat Sep 15 20:54:30 CEST 2007
-compilers.incompatible-environment=1
-compilers.p.build=1
-compilers.p.deprecated=1
-compilers.p.missing-packages=2
-compilers.p.no-required-att=0
-compilers.p.not-externalized-att=2
-compilers.p.unknown-attribute=1
-compilers.p.unknown-class=1
-compilers.p.unknown-element=1
-compilers.p.unknown-resource=1
-compilers.p.unresolved-ex-points=0
-compilers.p.unresolved-import=0
-compilers.use-project=true
-eclipse.preferences.version=1
+#Mon Jul 27 13:07:53 CEST 2009
+compilers.f.unresolved-features=1
+compilers.f.unresolved-plugins=1
+compilers.incompatible-environment=1
+compilers.p.build=1
+compilers.p.deprecated=1
+compilers.p.discouraged-class=1
+compilers.p.internal=1
+compilers.p.missing-packages=2
+compilers.p.missing-version-export-package=2
+compilers.p.missing-version-import-package=2
+compilers.p.missing-version-require-bundle=2
+compilers.p.no-required-att=0
+compilers.p.not-externalized-att=2
+compilers.p.unknown-attribute=1
+compilers.p.unknown-class=1
+compilers.p.unknown-element=1
+compilers.p.unknown-identifier=1
+compilers.p.unknown-resource=1
+compilers.p.unresolved-ex-points=0
+compilers.p.unresolved-import=0
+compilers.s.create-docs=false
+compilers.s.doc-folder=doc
+compilers.s.open-tags=1
+compilers.use-project=true
+eclipse.preferences.version=1
View
30 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/scion/ScionManager.java
@@ -44,6 +44,11 @@
private String serverExecutable = null;
private final Map<IProject, ScionInstance> instances = new HashMap<IProject, ScionInstance>();
+ /**
+ * Used to alert the user of Scion startup failure only once per session.
+ */
+ private boolean serverStartupErrorReported = false;
+
public ScionManager() {
// the work is done in the start() method
}
@@ -176,18 +181,21 @@ private void stopInstance( final ScionInstance instance ) {
}
private void reportServerStartupError(final ScionServerStartupException ex) {
- IStatus status = new Status(IStatus.ERROR, HaskellUIPlugin.getPluginId(), ex.getMessage(), ex);
- StatusManager.getManager().handle( status, StatusManager.LOG );
- HaskellUIPlugin.getStandardDisplay().asyncExec( new Runnable() {
- public void run() {
- Shell parent = HaskellUIPlugin.getStandardDisplay().getActiveShell();
- String text = NLS.bind( UITexts.scionServerStartupError_message, ScionPP.getServerExecutableName() );
- if ( MessageDialog.openQuestion( parent, UITexts.scionServerStartupError_title, text ) ) {
- PreferenceDialog prefDialog = PreferencesUtil.createPreferenceDialogOn( parent, ScionPP.PAGE_ID, null, null );
- prefDialog.open();
+ if (!serverStartupErrorReported) {
+ IStatus status = new Status(IStatus.ERROR, HaskellUIPlugin.getPluginId(), ex.getMessage(), ex);
+ StatusManager.getManager().handle( status, StatusManager.LOG );
+ HaskellUIPlugin.getStandardDisplay().asyncExec( new Runnable() {
+ public void run() {
+ Shell parent = HaskellUIPlugin.getStandardDisplay().getActiveShell();
+ String text = NLS.bind( UITexts.scionServerStartupError_message, ScionPP.getServerExecutableName() );
+ if ( MessageDialog.openQuestion( parent, UITexts.scionServerStartupError_title, text ) ) {
+ PreferenceDialog prefDialog = PreferencesUtil.createPreferenceDialogOn( parent, ScionPP.PAGE_ID, null, null );
+ prefDialog.open();
+ }
}
- }
- });
+ });
+ serverStartupErrorReported = true;
+ }
}
}
View
BIN  org.easymock/lib/easymock.jar
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.