Git Product home page Git Product logo

octave-doctest's People

Contributors

apjanke avatar catch22 avatar cbm755 avatar mmuetzel avatar mtmiller avatar oheim avatar tgs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

octave-doctest's Issues

Feature Request: Add summary at the end of test results

The coloured output is not good enough to quickly see whether there are failures or not when there are many files to be checked.

Please add a summary line add the end. Useful information: total number of PASS´ed and FAIL´ed example blocks; total number of files without example blocks (see run_test_suite console output as a reference).

Allow default directives

Eventually it would be nice to specify the NORMALIZEWHITESPACE default on the command line.

E.g.,
doctest . -recurse -NORMALIZEWHITESPACE

or
doctest . -recurse +NORMALIZEWHITESPACE

(Not necessary for 0.4.0.)

Number formatting differences

By default, MATLAB formats numbers using 4 digits after the decimal point (and some special-casing for 0), while Octave uses 5 digits. Do we want to enforce a certain output format (either long or bank) so that doctests can be written in a robust way in both systems? Hmm...

`myevalc` harmful on matlab

sorry, didn't properly test the merge request I sent earlier! There is a trivial typo but even fixing that it gives errors like this:

 ??? Error using assignin Attempt to add "x" to a static workspace. See MATLAB Programming, Restrictions on Assigning to Variables for details.

I can fix this but not tonight.

time to release v0.4.0

Assuming my classdef code is ok, is there anything else anyone would like for 0.4.0?

I'd like to get this into octave-forge. We can do a 0.4.1 for anything that brings up.

Tests with `<` or `>` will fail

nolove.m:

function s = nolove()
% >> s = nolove()
% s = <3

s = sprintf('<3');

Then doctest nolove:

octave:2> doctest nolove
Doctest v0.3.0-dev: this is Free Software without warranty, see source.
nolove: 1 ERRORS
  >> s = nolove()

     expected: s = <3
     got     : s = <3

Doctest Summary:

  Searched 1 targets: found 1 tests total, 0 targets without tests.
  Extraction errors: 0
  Tests passed: 0/1

I've traced this error to regexptranslate which escapes < and > but perhaps should not. Will test further later but quite possible upstream Octave bug.

octave/matlab differences for `methods(<class>)`

In Symbolic, I have a @logical dir which adds a single method (isAlways) to the logical class.

  • In Matlab, methods('logical') gives all sorts of stuff abs, all, amd, any, etc and including my isAlways method.
  • In Octave, methods('logical') gives just isAlways.

Maybe this is an upstream Octave bug.

But even in the Matlab case, should doctest then call doctest on all of these methods? Even those not defined in this 'project'? This is good for a user, but for package maintainer, I want to doctest my local stuff...

octave: multiline input not working

Something wrong with the example_re regexp on Octave. Seems ok on Matlab.

Even fails its own tests (doctest doctest)

>> A = [1 2 3
.. 4 5 6
.. 7 8 9]
<output>

The regex matches three things instead of two, returning a cell array with the correct input but then then .. 7 8 9] where the output is expected and finally an extra match for the real output.

OctaveForge package design

@catch22 Let's (eventually) pick one of these.

  • we can be a Octave package that also generates a Matlab-appropriate zipfile for releases. Code could live in inst/, various other rules. PR #34.
  • we can be a continue as a Matlab package (note this is not well-defined) and have some script that generates Octave packages. [going with first approach].

Also:

  • In Octave, we will probably be "Octave-Forge Doctest Package" or something like that. [sort of done in DESCRIPTION file].
  • The "official" software name is "Doctest For Matlab". License.txt refers to this for example. Is there any legal problem problem here? [no]
  • Do we want a new name that is less confusing? [yes, the repository is now called octave-doctest.]
  • If new name, do we keep the original License.txt and have a new COPYING? [No, just attribute to @tgs and keep copyright notices up-to-date.]
  • Move DESCRIPTION file to root. 4f1bc79

PAGER, PAGER_FLAGS override: sometimes hangs

I'm not exactly how reproducible this is...

If I enable the PAGER etc hack that is commented out, and generate some sort of error condition during the doctests, then I never get my prompt back. If I ctrl-C, I sometimes get:

KeyboardInterrupt

warning: connection to external pager lost (pid = 12783)
warning: flushing pending output (please wait)

Other times I get just get KeyboardInterrupt and my prompt back.

How to reproduce:
At least on my system:

  1. start a new Octave instance, load the symbolic pkg
  2. syms x (Symbolic spews some stdout and stderr at first start while connecting to Python. Leave this step out to reproduce.)
  3. doctest symfun.

Without step 2, the stdout/stderr noise from symbolic startup makes the first doctest fail (this is understandable) but it also activates this bug:

octave:2> doctest('bernoulli', 'sym')
Doctest v0.3.0-dev: this is Free Software without warranty, see source.
==========================================================================
Start of temporary output (github.com/catch22/octave-doctest/issues/6)
==========================================================================
Python 2.7.9 (default, Apr 15 2015, 12:08:00) 
[GCC 5.0.0 20150319 (Red Hat 5.0.0-0.21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 



^C
KeyboardInterrupt
>>> 
octave:2> 

`got` can start/end with arbitrary stuff as long as it contains `want`

This looks like a pretty serious bug. Consider:

function a = doctest_bug(c)
% Here's an innocent-looking test:
%
%   >> display('hello world')
%   hello world
%
%
% All looks well, but try:
%
%   >> display('BUG BUG hello world Muhahahaha')
%   hello world
%
%
% Hmmm...

Both tests pass.

The problem is presumably in doctest_compare:

result = regexp(got, want_re, 'once')

Here want_re has no anchors to beginning and end. I relying on this thinking it was just smart enough to parse out "ans = ", but no its just easy to trick it :)

Octave: "fake_evalc" spams stdout

evalc is supposed to capture the stdout and not echo it. My fake_evalc fcn does the first but not the latter. I don't see any easy way around this without doing something icky with PAGER.

The right thing to do is probably to fix Octave.

But if someone knows a quick workaround for fake_evalc then let me know...

Release v0.3.0

Should we release a version 0.3 with the old API? Let's not advertise it very much because of the incoming new API (issue #37, PR #38). @cbm755 would you like to do that?

Allow +SKIP/+XFAIL depending on runtime condition

We would like to be able to state things like that the doctest of test_angle_brackets is expected to fail for Octave versions <= 3.8.2. We could achieve this by some magic comment like

% >> s = test_angle_brackets()
% s = I <3 U
% XFAIL Octave<=3.8.2

but perhaps there is a simpler way?

Texinfo files: Support more file extensions

It should be possible to use extensions .texinfo, .tex and .txi in addition to .texi.

I have suggested to try detection of Texinfo file by scanning the file for “\input texinfo”. This is not a good idea, because Texinfo @include files should also be supported.

`doctest class` used to test methods, now doesn't

strange "make test" passes. But interactively:

>> doctest({'doctest', 'test_class'})

doctest ............................................................... PASS    6/6   
test_class ............................................................ EXTRACTION ERROR

    Function or class not found.


Summary:

   PASS    6/6   

1/2 targets passed, 0 without tests, 1 with extraction errors.

Matlab fails after skip patch

Doctest v0.4.0-dev: this is Free Software without warranty, see source.
doctest ................................................ Error using ones
CLASSNAME input must be a valid numeric class name.

Error in doctest_run (line 28)
keep = ones(size(examples), 'logical');

Error in doctest (line 313)
  results = doctest_run(target.docstring);

testing files that do not exist gives unhelpful error

>> doctest doctset
error: javaMethod: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.45-31.b13.fc22.x86_64/jre/lib/amd64/server/libjvm.so: failed to load: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.45-31.b13.fc22.x86_64/jre/lib/amd64/server/libjvm.so: cannot open shared object file: No such file or directory
error: called from
    methods at line 45 column 16
    doctest_collect at line 59 column 9
    doctest at line 244 column 11

fopen warning

I get warning: fopen: file found in load path since a little while. Is this because of the .texinfo files that get fopened from the path?

(I think this might get auto-fixed as we add support for test collection in directories...)

non-word output is incorrectly ignored

Consider a test which outputs chars that are not words (in the regular expression sense):

>> '[{... + .  [  ] ...'
[{... + .  [  ] ...

Then the test will fail, probably because of the \w in example_re regexp in doctest_run.m.

Easy to trigger in Octave because of the way it renders cell-arrays.

doctest_evalc installation

Two questions for @oheim and @cbm755:

  1. Currently we are invoking src/Makefile from the root Makefile and add src to the Octave path so that doctest_evalc is found. Is this the correct way to set up the testing infrastructure? Or should we install the package before running doctests on it? Or is there something like Python's setup.py develop?
  2. Is it possible to have doctest_evalc be installed into inst/private rather than inst (the latter is the current behavior, right?).

Should we provide a fallback for doctest_evalc?

The octave packages of Debian and Ubuntu do not come with mkoctfile and hence are not always installed. Not sure if we should provide the old fake_evalc as a fallback (+ buffering support...).

improve white space matching

Currently, we collapse all whitespace to single space chars before comparing. It might be better to:

  1. strtrim each line. This was, result can be indented arbitrarily.
  2. collapse/ignore blank lines.

Not urgent. Needs something like #67 for its tests.

Matlab and Octave have different conventions for formatting matrices so this might slightly touch on #35.

Octave: wrong totals output by "test_anything()"

Here there are 8 tests in total. to_test has size 21x1 and results has size 1x8. Instead of seeing which have tests and which have no tests, I get some random-looking numbers:

symfun: OK (64 tests)
@symfun/argnames: OK (115 tests)
@symfun/diff: OK (121 tests)
@symfun/formula: OK (109 tests)
@symfun/int: OK (102 tests)
@symfun/ldivide: OK (117 tests)
@symfun/minus: OK (110 tests)
@symfun/mldivide: OK (47 tests)
@symfun/mpower: OK (97 tests)
@symfun/mrdivide: OK (114 tests)
@symfun/mtimes: OK (103 tests)
@symfun/numel: OK (110 tests)
@symfun/plus: OK (97 tests)
@symfun/power: OK (109 tests)
@symfun/priv_disp_name: OK (101 tests)
@symfun/rdivide: OK (115 tests)
@symfun/subsref: OK (64 tests)
@symfun/symfun: OK (115 tests)
@symfun/symvar: OK (121 tests)
@symfun/times: OK (109 tests)
warning: implicit conversion from scalar to sq_string

I'm not sure how this is supposed to work but the error has something to do with the vectorized fprintf:

fprintf(out, '%s: OK (%d tests)\n', to_test.name, length(results));

note length(results) is a scalar (8).

Again, I'll try to look into this further when I get a chance.

recent change to workaround #6 causes errors for me

I get lots of errors, although it seems to run the test:

>> doctest({'doctest'})
doctest ................................................ cat: invalid option -- 'X'
Try 'cat --help' for more information.
cat: invalid option -- 'X'
Try 'cat --help' for more information.
cat: invalid option -- 'X'
Try 'cat --help' for more information.
cat: invalid option -- 'X'
Try 'cat --help' for more information.
warning: connection to external pager lost (pid = 5300)
warning: flushing pending output (please wait)
PASS    6/6   

Summary:

   PASS    6/6   

1/1 targets passed, 0 without tests.

>> 

support `doctest: +XFAIL`

Or some command like that. We can use this for:

  1. Our own tests were we want to test that a certain doctest does not pass.
  2. For known failures that will eventually be fixed.

For now, I suggest just inverting the usual logic. That is, passing an XFAIL test is an error. This is slightly different from Octave test behaviour but its easier to implement and enough for 1. above.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.