Using HTF

Help
2013-02-06
2013-02-11
  • Ernesto Posse

    Ernesto Posse - 2013-02-06

    Hi. I'm having trouble with HTF. Below is my original message which I sent to the
    eclipsefp-develop@lists.sourceforge.net mailing list, and I'm reproducing it here (with the response) for reference.

    Basically HTF doesn't run for me, and the "Validate" and "Run as..." options don't appear in the context menu.

    The project itself is built. I checked and it appears under .dist-buildwrapper/dist, but the executable for the test-suite is not being generated. The console shows the following error:

    buildwrapper: buildwrapper: could not execute: htfpp
    configuring because setup_config not present
    
    buildwrapper: buildwrapper: could not execute: htfpp
    buildwrapper: buildwrapper: could not execute: htfpp
    buildwrapper: buildwrapper: could not execute: htfpp
    

    I tried running htfpp directly on the .hs files in the test suite (both the main, and the test modules). The output of htfpp seems to be OK.

    The only problems are warnings (about the code generated by alex) but there are no errors.

    I'm a bit lost as all this is in a fresh installation of EclipseFP 2.4.2 (on Eclipse 4.2.1), and the haskell platform with ghc 7.4.2 and cabal 1.14.0, on Ubuntu 12.10. There where no errors during the installation of any of the auxiliaries, including BuildWrapper 0.6.4, Scion 0.2.13, Hoogle 4.2.15, Hlint 1.8.43, SourceGraph or HTF 0.10.0.7. And running "ghc-pkg check" reports no errors or warnings.

    Thanks

    On Wed, Feb 6, 2013 at 12:48 AM, Ernesto Posse eposse@cs.queensu.ca wrote:

    Hi. I'm Trying to use HTF for testing and I followed the YouTube tutorial, but I'm >running into trouble. Once the test suite has been generated I'm unable to run it. The >video shows that a right-click on the project displays the context menus with options >"Validate" (above "Run SourceGraph"), "Run As..." and "Debug As..." (just below "Cabal >Install"). My first problem is that I don't get these options at all. I see that there >is a "Test Suites entry created, and when I right-click the test suite executable I do >get the options "Run as HTF test", etc. But when I click it I get a dialog asking me to >select a launch configuration to run, but there are no configurations to choose from and >the "OK" button is disabled.

    I tried creating my own run configuration under HTF test, but I'm not sure what should I >give as "Working Directory", and there is no option to specify the executable, so when I >try to run it, I get an error saying that it could not locate the executable to launch.

    So what can I do?

    Thanks.

    On Wed, Feb 6, 2013 at 3:06 AM, JP Moresmau jpmoresmau@gmail.com wrote:

    Ernesto, this means the project hasn't been built, so the executables don't exist (they >would be under the .dist-buildwrapper/dist folder). Ether you forgot to build the >project if you're not in auto build mode, or there is a problem preventing EclipseFP >from building the project. There are no problem markers indicated on the project? Then >check the console called buildwrapper output for project YourProject and see if there >are any meaningful errors there.

    Hope this helps.

    JP

    PS: This list is not used much. Post issues on >http://sourceforge.net/p/eclipsefp/discussion/371922 instead.

     
  • JP Moresmau

    JP Moresmau - 2013-02-06

    htfpp is probably not in the path EclipseFP is running with. Ensure it's in the path so that buildwrapper can find it.

     
    • Ernesto Posse

      Ernesto Posse - 2013-02-06

      Hmm... This is strange. htfpp (as well as buildwrapper) is installed under

      /home/eposse/.cabal/bin
      

      which is on my PATH. This is where cabal installed it.

      Eclipse itself is on /home/eposse/Local/Apps/eclipse/ and my workspace is on /home/eposse/Projects.

      I don't see any place to tell EclipseFP where to find htfpp. I've looked under Window -> Preferences -> Haskell -> Helper executables and under the project's Properties but I didn't see any setting related to it. Is there such a setting somewhere?

       
  • JP Moresmau

    JP Moresmau - 2013-02-06

    No, because EclipseFP doesn't deal with htfpp directly, the instruction to use it is in the source code so it's invoked when it gets compiled by GHC or cabal.
    If you run cabal configure -- enable-tests && cabal build on the command line, does the project get built successfully?

     
  • Ernesto Posse

    Ernesto Posse - 2013-02-06

    Yes, it builds the project successfully (on a folder "dist", not under .dist-buildwrapper/dist). The test suite executable works fine on the command line, but it doesn't work on EclipseFP. I still get the buildwrapper error, and no options on the context menu.

     
    Last edit: Ernesto Posse 2013-02-06
  • JP Moresmau

    JP Moresmau - 2013-02-06

    And you're sure that the path you have in the shell is the same that is used by EclipseFP? For example, can EclipseFP autodetect where buildwrapper is? Otherwise I'm a bit stumped, since building the project via BuildWrapper involves calling cabal build, so really we're not doing much, expect using .dist-buildwrapper/dist instead of the standard dist...

     
  • Ernesto Posse

    Ernesto Posse - 2013-02-06

    I'm not sure if it's the same path (or how to check) but I think EclipseFP can auto-detect the right path because under Window -> Preferences -> Haskell -> Helper executables it shows the path for buildwrapper to be /home/eposse/.cabal/bin/buildwrapper and I didn't enter that manually.

    But on top of that, why doesn't it show the "Run as..." option in the context menu? Shouldn't that be shown independently of HTF?

     
  • JP Moresmau

    JP Moresmau - 2013-02-06

    Run As on the project requires executables to be found under .dist-buildwrapper, so if building fails for some reason, you won't have it. So we need to understand why the htfpp step fails.

     
  • Ernesto Posse

    Ernesto Posse - 2013-02-06

    But the strange thing is that the normal executable is generated and found under .dist-buildwrapper and runs without trouble. It's only the test suite executable the one that's missing.

     
  • JP Moresmau

    JP Moresmau - 2013-02-06

    The test suite executable is the only one with modules using the htfpp preprocessor, no? So that's normal. Maybe contact the HTF maintainer (Stefan Wehr) see if he has any idea... I use HTF in my own projects without any issue...

     
  • Ernesto Posse

    Ernesto Posse - 2013-02-06

    Yes, the test suite is the only one using htfpp. I just tried again removing the whole haskell-platform, including my local .ghc and .cabal folders and uninstalling EclipseFP, and reinstalling everything. I get the same result.

    The only thing that occurs to me that could be causing the problem some sort of conflict with other Eclipse plugins. Aside from a plain vanilla Eclipse I installed PyDev. Is there any known conflict with it?

    I'll ask Stefan, but I doubt the issue is on that end, since the test-suite executable is generated correctly on the command-line and when I run it I get the expected results from HTF.

     
  • JP Moresmau

    JP Moresmau - 2013-02-07

    No, not a conflict with other plugins, since the error is from inside BuildWrapper, which is a Haskell executable. It looks like when BuildWrapper invokes cabal build it doesn't find htfpp. You can try to clean the project using the Eclipse Clean action (Project -> clean) which will relaunch the whole configure/build process, see if that changes anything.

     
  • JP Moresmau

    JP Moresmau - 2013-02-07

    Ernesto, can you turn on debug mode for buildwrapper, so we understand which call to buildwrapper fails? In the preferences, under the text box where you enter the executable. So we should see the requests and responses from buildwrapper. Thanks

     
  • JP Moresmau

    JP Moresmau - 2013-02-07

    OK, thanks. It looks it fails after a build command, and the build command fires cabal build, so it looks not like a buildwrapper issue but more like an env issue, but the hell if I can figure it out. I'm pretty sure the message is launched by GHC, search for "could not execute" in http://www.haskell.org/ghc/docs/7.4.2/html/libraries/ghc-7.4.2/src/SysTools.html#runPp . So it does look like the executable fails or is not found, but GHC does not give us more detail.
    So if it works in the shell, open a shell at the root of your project, and type in the build command as the output showed it:
    /home/eposse/.cabal/bin/buildwrapper build --output=true --cabaltarget=Source --tempfolder=.dist-buildwrapper --cabalpath=/usr/bin/cabal --cabalfile=/home/eposse/Dropbox/Projects/htftest/htftest.cabal --cabalflags=

     
  • Ernesto Posse

    Ernesto Posse - 2013-02-07

    I get this on the command-line.

    build-wrapper-json:[{"r":true,"fps":["tests/MyPkg/MyModTest.hs","tests/MyTS.hs"]},[{"l":{"c":1,"ec":1,"f":"tests/MyPkg/MyModTest.hs","l":3,"el":3},"s":"Warning","t":"The import of MyPkg.MyMod' is redundant\n except perhaps to import instances fromMyPkg.MyMod'\n To import instances alone, use: import MyPkg.MyMod()\n"}]]

    It does not seem to fail, and it does seem to generate the executable correctly under .dist-buildwrapper/dist.

    So it does look like it is a problem of calling it within Eclipse.

     
  • JP Moresmau

    JP Moresmau - 2013-02-07

    Great! At least it's not my software doing something silly. Ok, so now check in Eclipse, Help -> About Eclipse -> Installation Details -> Configuration and search for java.library.path, which I think would represent the path as Eclipse sees it. Checks that the htfpp location is in there correctly. You're not running Eclipse as a different user or something like that? On that page https://cwiki.apache.org/WICKET/setup-eclipse.html#SetupEclipse-Subclipse they talk about adding a line on the eclipse.ini file to add a location to the path and they mention specifically Ubuntu...

     
  • Ernesto Posse

    Ernesto Posse - 2013-02-07

    It shows this:

    java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib

    which doesn't contain any of my path folders, not even my ~/.cabal/bin.

    I've edited eclipse.ini to add it and now it works! Great!

    It's still not showing the context menu options, though, but I can live without them. I just have to right-click on the generated test executable and that one does have the "Run as HTF test" option.

    Thank you very much!

    PS: Great work on this tool.

     
  • JP Moresmau

    JP Moresmau - 2013-02-07

    OK great! I've checked in the code, and the thing is that to detect executables like buildwrapper, we actually check in the PATH, but also in $home/.cabal/bin, etc. So that's what made it confusing: EclipseFP can find executables that are not on the path, which is great, except when then buildwrapper doesn't know about these extra paths. I'll look at adding a warning when an executable is detected outside the path, maybe, or see if I can pass the path to where cabal puts its executables to buildwrapper.
    Thanks for your patience and your help in resolving the issue. Context menu on the project should work though, let me know if you can't get that to work.

     
  • Ernesto Posse

    Ernesto Posse - 2013-02-08

    After more experimentation I realized that the problem was not the java.library.path variable, which only tells java where to find external libraries. Rather the problem is the environment in which eclipse itself is executed. So when I started eclipse from the command-line it recognized my PATH and everything was OK, but when I started it from nautilus or from the Ubuntu launcher it failed. It turns out that when you do that in Ubuntu, it executes the program on a fresh shell which does not have your user-specific environment variables.

    So even though it is not an EclipseFP issue per se, I'll share my solution (this is relevant only for Ubuntu and maybe other Linux distros):

    1) create a batch script called e.g., "my-eclipse.sh" to launch eclipse with your specific relevant environment variables: (save it under ~/.local/bin)

    1
    2
    3
    4
    5
    #!/bin/bash
    
    export PATH=$HOME/.cabal/bin:$HOME/.local/bin:$PATH
    
    eclipse
    

    2) make it executable:

    chmod +x myeclipse.sh
    

    3) edit or create an eclipse.desktop file to contain the following: (it should go under ~/.local/share/applications)

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    #!/usr/bin/env xdg-open
    
    [Desktop Entry]
    Type=Application
    Name=Eclipse
    Comment=Eclipse Integrated Development Environment
    Icon=eclipse
    Exec=$HOME/.local/bin/my-eclipse.sh
    Terminal=false
    Categories=Development;IDE;Java;
    Name[en_CA]=Eclipse 4.2 Juno
    

    4) make it executable

    chmod +x eclipse.desktop
    

    Then you can launch eclipse by executing this eclipse.desktop, and it will recognize the PATH as you define it on "my-eclipse.sh".

    Even though this has fixed the problem I noticed that a couple of times I got another, different message from buildwrapper (see attached file). It still succeeds in building the test, but at one point shows:

    buildwrapper: <command line>: cannot satisfy -package-id htftest-0.1-inplace
    (use -v for more information)
    

    which is weird because HTF is correctly installed, and it does not always appear.

    As for the context menu, I still can't get it to show the other options. I've no idea what could be the problem.

     
  • JP Moresmau

    JP Moresmau - 2013-02-11

    I think for the moment you can ignore that message, the generation of the usage database works in a different thread and things are not always properly synchronized, I'll look into it. Otherwise, I've made sure that the path to buildwrapper is added to the PATH used when launching it, so that it should find executables that are in the same folder. Would have solved your problem.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks