Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Travis testing #37

Merged
merged 59 commits into from
May 28, 2018
Merged

Travis testing #37

merged 59 commits into from
May 28, 2018

Conversation

TomMaullin
Copy link
Collaborator

This PR aims to implement Travis Testing for the SPM html viewer using Docker containers and Octave.

@TomMaullin
Copy link
Collaborator Author

TomMaullin commented May 3, 2018

Whilst creating this PR I have come across the following issue. The below command I believe should run the testing suite for the SPM viewer in a docker container on my machine.

sudo docker run -ti -v /home/tommaullin/Documents/Repos/nidmresults-spmhtml/test:/test cmaumet/octave-spm octave --no-window-system --eval "addpath('/test'); runTest()"

This appears to run the code as required. However, Octave throws an error saying it doesn't have the import function (which is used to load the matlab unittesting framework library).

"error: the import function is not yet implemented in Octave"

I found a fix on stack overflow here but this has given no luck as it has just transformed the error to this:

"warning: function /test/import.m shadows a core library function error: invalid package name: matlab.unittest.TestSuite"

This PR may be put on hold until the next Octave release.

@gllmflndn
Copy link
Collaborator

The matlab.unittest framework is not available in Octave and it would be a rather big task to implement it in its entirety. From what I can see in the tests here, you don't use many of its functionalities though so I wonder whether we could have a small workaround or use something like MOdox instead.

@TomMaullin
Copy link
Collaborator Author

Ah I see - Thank you for clarifying this! Do you know of any example repositories than currently contain a MOdox-based testing suite?

@cmaumet
Copy link
Member

cmaumet commented May 3, 2018

@TomMaullin
Copy link
Collaborator Author

I am a little confused by this foo.m example in the readme.md. I will see if I can find further examples online and let you know how it goes!

@gllmflndn
Copy link
Collaborator

That's because I gave you a link to the wrong project, have a look at MOxUnit instead. Sorry!

If you were OK to use function-based unit tests instead of class-based ones, we could otherwise write a little wrapper for Octave.

@TomMaullin
Copy link
Collaborator Author

TomMaullin commented May 3, 2018

Ah - no worries! Yes, this is exactly what I was looking for - Thank you!

I see no reason why these tests couldn't be function based instead of class based... I believe, if I remember correctly, I actually wrote these as functions first before plugging them into the matlab unit testing framework. I think this is why they barely make use of the class structure.

@cmaumet what do you think of this suggestion? I quite like the look of the MOxUnit tests and I don't believe it would be too much work to convert the current tests into this format.

@cmaumet
Copy link
Member

cmaumet commented May 3, 2018

@TomMaullin: I would vote for the option that is the easiest to implement so pretty much up to you :)

@TomMaullin
Copy link
Collaborator Author

Okay great! I'll give the MOxUnit tests a go and let you know how they go!

@TomMaullin
Copy link
Collaborator Author

TomMaullin commented May 4, 2018

I have been using Octave a bit more recently and realized that the NIDMResults viewer itself does not run on Octave (many of the functions it uses are not currently implemented in Octave). As the tests themselves run the viewer, I am unsure we will be able to test this repository on Travis using dockers with Octave unless the viewer itself is also Octave-friendly.

An example of the issue is given by running the command below in the cmaumet\octave-spm docker container, having installed all of the relevant packages:

octave --no-window-system --eval "addpath(genpath('/nidmresults-spmhtml/'));nidm_results_display('testDataSets2.m')"

This results in:


Please read <http://www.octave.org/missing.html> to learn how you can
contribute missing functionality.
error: 'contains' undefined near line 17 column 8

I at first tried making temporary files to replace the missing functions but I think there are quite a lot of missing functions. I'm honestly not sure how to move on from here. @cmaumet I was wondering, how did you get SPM running in Octave? Is SPM octave-friendly?

@gllmflndn
Copy link
Collaborator

The NIDM-Results export from SPM should work with Octave 4.4. Could you list the missing functions that you are trying to use? You mention contains (endsWith would be more adequate here but is not yet available either) but it is only available since R2016b so you would anyway be better off checking the file extension with fileparts/strncmp.

@cmaumet
Copy link
Member

cmaumet commented May 22, 2018

@TomMaullin: can you rebase on master in order to include the octave-compatibility updates from #38? And then we can check if the tests pass?

@cmaumet
Copy link
Member

cmaumet commented May 23, 2018

Thanks @TomMaullin! I've just enabled Travis CI for this repository and created a dummy commit to trigger the tests.

Copy link
Member

@cmaumet cmaumet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! Thanks for making this work!! I only have a couple of comments of external files you have included in the repo.

Regarding your question on keeping the test suite that is using unittest for Matlab testing, could you let us know what is your preferred option?

@@ -0,0 +1,71 @@
## Copyright (C) 2012 Rik Wehbring
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomMaullin: is it normal that you have included this chi2inv.m file in the version-control?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah apologies... I thought I had removed this! I'll remove it now!

@@ -0,0 +1,204 @@
classdef spm_file_template
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we patch on-the-fly as suggested by Guillaume in #38 (comment)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Right! I had misunderstood here, yes I will change this! I thought this was intended to go in the docker image eventually.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully it's only temporary as SPM dev includes the workaround and there is a patch submitted for Octave.

@TomMaullin
Copy link
Collaborator Author

TomMaullin commented May 23, 2018

Hi @cmaumet ,

My preference would be to keep both versions of the testing framework, both MOxUnit and matlab unittesting framework. The reason for this is that MOxUnit works on Travis whereas matlab unittesting framework does not, but while developing and making changes locally I find the matlab unittesting framework tests are much faster and convenient than MOxUnit as they involve no setup or bug fixes.

Copy link
Collaborator

@gllmflndn gllmflndn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! The Octave statistics package should probably be installed through pkg() but do you actually need it? From what I can see, you could just use the spm_*pdf.m and spm_*cdf.m functions from SPM.

@TomMaullin
Copy link
Collaborator Author

Hi @gllmflndn , Oh right! Yes, I hadn't thought of that - that would make life a lot easier! I'll give this a go and let you know how smoothly it goes on Octave!

@TomMaullin
Copy link
Collaborator Author

TomMaullin commented May 23, 2018

Quick update: The SPM functions worked and the octave-statistics dependency has been removed. Thank you for the suggestion @gllmflndn !

.gitignore Outdated
@@ -11,6 +11,8 @@ Data/*.png

# Test data (if missing will be downloaded from NeuroVault)
test/data
test/MOxUnit
test/octave-statistics
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this from .gitignore, now that the code is not depending anymore on octave-statistics?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, yes this is now done!

@cmaumet
Copy link
Member

cmaumet commented May 24, 2018

@TomMaullin: Great!! And let's keep both versions of the tests then! Could you document alternative ways to run the tests using: 2/ Octave and 3/ Octave+docker in the README? Also, do we need to put back runTest.m for testing in Matlab? I currently get the following error:

>> addpath(fullfile(fileparts(which('nidm_results_display')), 'test'))
>> runTest();
Undefined function or variable 'runTest'.

Once this is done, +1 to merge.

@TomMaullin
Copy link
Collaborator Author

@cmaumet , great! I will do this!

Yes, currently the Matlab unittests have been removed so the original way of calling the tests no longer works. But I will add them back in and document everything!

@TomMaullin
Copy link
Collaborator Author

TomMaullin commented May 25, 2018

Hi @cmaumet ,

Both testing suites are now available and documented in the readme.md. Please let me know if you have any further feedback.

@cmaumet
Copy link
Member

cmaumet commented May 28, 2018

Thanks! +1 to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants