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

Test manualexamples #1082

Merged
merged 1 commit into from
Feb 6, 2017
Merged

Conversation

markuspf
Copy link
Member

This is not yet finished, and rather hacky. Feel free to comment though.

At the moment a lot of the tests fail because of screen width problems etc.

@markuspf markuspf added the do not merge PRs which are not yet ready to be merged (e.g. submitted for discussion, or test results) label Jan 17, 2017
@markuspf markuspf self-assigned this Jan 17, 2017
@markuspf
Copy link
Member Author

First stab at addressing #1076

@olexandr-konovalov
Copy link
Member

@markuspf thanks. Have you seen my last comment in #1076 btw?

Immediate remark: this

########> Diff in /home/travis/build/gap-system/gap/tst/testmanuals/chapter64.\
tst:594
# Input is:
Basis(L)[17]^vv[100];
# Expected output:
-1*y5*y7*y8*v0-1*y5*y9*v0
 ]
# But found:
-1*y5*y7*y8*v0-1*y5*y9*v0
########

refers to lines in the test file. One should now go there to figure out from which source file this example is taken (if this is recorded at all). To the contrary, the current setup refers to the actual location of the manual example, avoiding such indirection. IMHO this is an important feature.

@olexandr-konovalov
Copy link
Member

@markuspf cf. pkg/wedderga/makedocrel.g - I am extracting examples from he package manual there. Produced test files are not kept under version control but are included in the package release. This involves redirection, but at least the test files records the location of the original example in the comment.

@markuspf markuspf force-pushed the test-manualexamples branch from c86fcba to ef42f42 Compare January 17, 2017 10:55
@codecov-io
Copy link

codecov-io commented Jan 17, 2017

Current coverage is 56.88% (diff: 100%)

Merging #1082 into master will increase coverage by 0.05%

@@             master      #1082   diff @@
==========================================
  Files           433        434     +1   
  Lines        224901     224996    +95   
  Methods        3447       3447          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits         127806     127989   +183   
+ Misses        97095      97007    -88   
  Partials          0          0          

Powered by Codecov. Last update 34f3178...421cf25

@markuspf markuspf force-pushed the test-manualexamples branch from ef42f42 to c9c7948 Compare January 17, 2017 12:13
@markuspf
Copy link
Member Author

This is starting to look better after I hit it repeatedly with a hammer.

@markuspf
Copy link
Member Author

This fragility is making me really sad.

@markuspf markuspf force-pushed the test-manualexamples branch from 239fddb to 10f9aa5 Compare January 17, 2017 14:09
@markuspf
Copy link
Member Author

There are still a few tests that fail, maybe we should ignore these failures in travis and just add the improved coverage to codecov though. Feel free to chase up the remaining diffs...

@fingolfin
Copy link
Member

First, off: Thanks for working on this.

As @alex-konovalov already pointed out, some of those test failures are spurious, either due to randomness, irrelevant side effects, etc. etc. I think we really should try to fix these properly. Becaue what Alex has been doing manually (i.e. curating the test results with a lot of manual work) simply does not scale.

So, it would indeed be good if people could help to improve this. Some things that will help:

  • Merge PR Fix regression in group constructors for matrix groups #1077 (which so far has not been reviewed hint hint ;-).
  • For some tests, we may wish to suppress some output
  • For the AssignGeneratorVariables we might want to modify the InfoWarning and/or InfoGlobal level (just for the manual tests, perhaps?)
  • Some tests should simply be changed from <Example> to <Log> (both look the same to users, but only the former gets tested, not the latter)
  • Improve our test system (we need to do that anyway), e.g. to allow us to insert meta data which indicates splits in the tests inside of chapters. As a minimal version, that might be some kind of marker which tells us "test everything up to this point; then reset everything, e.g. by restarting GAP" -- right now, we only do that at chapter borders, which may be too broad.
  • In some cases, the outputs in the manual simply may be out of date and should be updated...

Hmm... Markus, could you perhaps hack this some more, and add two more travis tests, with gap -A and with LoadAllPackages? It would be really interesting to know how bad those fail. (To do this, I would retain a single testmanuals.g, but add environment variables which specifies the extra modes... perhaps GAPFLAGS=-A and then change etc/ci.sh to pass those to gap.sh; and a second env which testmanuals.g checks for and if set, it executes LoadAllPackages()

(Note: I would try it on my local machine, but I am afraid that my set of packages is vastly different from what is bundled with GAP; in fact, for me LoadAllPackages() runs into an error; I can reenter it several times to get more and more packages, but usually it eventually causes GAP to crash...)

@fingolfin
Copy link
Member

It seems that a ton of diffs are also caused by X(Rationals,1) having a non-default name (x instead of x_1). But that's very strange: If I manually run the tests (e.g. Test("tst/testmanuals/chapter58.tst"); then this diff does not crop up....

Oh wait: You are not restarting GAP after every chapter, are you? That would explain a big bunch of these diffs...

@markuspf
Copy link
Member Author

I am indeed not restarting GAP for every test.

I have a hacked up version of TestDirectory that can use IO_fork to run the tests, not sure yet whether this is a good idea though.

@ChrisJefferson
Copy link
Contributor

Just as a point, I've had to make a separate hack based on IO_fork for the profiling package, as I also need to run each test in a separate GAP (my hack was far too hacky to be in GAP). I think it's a sensible thing to do.

@fingolfin
Copy link
Member

fingolfin commented Jan 17, 2017

Well, if you have working code, fine.. though what I would do is create a shell script which loops over the test files and starts GAP with each of them. This could then also use a workspace to speed up things a bit. Of course a little bit extra work is needed if we don't want to abort the script after the first chapter with failures.

This could then also be used on Windows (if we wanted to), while IO_fork might be problematic there...

Anyway, whatever works is fine by me.


# RS := rec(changeSources := true);
# WS := rec(compareFunction := "uptowhitespace");
# WSRS := rec(changeSources := true, compareFunction := "uptowhitespace");
Copy link
Member

Choose a reason for hiding this comment

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

What are these comments about?

##

# This code extracts the examples from manuals chapter-wise and
# stores this in a workspace.
Copy link
Member

Choose a reason for hiding this comment

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

Where does it store anything in a workspace?

Print("Extracting manual examples...\n");
Read(Filename(DirectoriesLibrary("doc/ref"), "makedocreldata.g"));

GAPInfo.ManualDataRef.pathtodoc := DirectoriesLibrary("doc/ref");
Copy link
Member

Choose a reason for hiding this comment

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

Minor nitpick: DirectoriesLibrary("doc/ref"); occurs twice, perhaps reorder and use GAPInfo.ManualDataRef.pathtodoc in the Read ? Not that it matters much...

Copy link
Member

Choose a reason for hiding this comment

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

Of course keeping the Read as it is can be convenient when debugging this file, as it allows one to copy&paste that line into a GAP session.

So an alternative would be to get rid of GAPInfo.ManualDataRef.pathtodoc (or is it used outside of this script). There is only one place here using it...

PrintTo(output, "#### Reference manual, Chapter ",i," ####\n",
"gap> START_TEST(\"", chname, "\");\n");
for a in ch do
AppendTo(output, "\n#LOC# ", a[2], a[1]);
Copy link
Member

Choose a reason for hiding this comment

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

Another minor nitpick: You switch between PrintTo and AppendTo. I think they do the same for streams anyway, but using both might confuse somebody who doesn't know that...

Read(Filename(DirectoriesLibrary("doc/ref"), "makedocreldata.g"));

GAPInfo.ManualDataRef.pathtodoc := DirectoriesLibrary("doc/ref");
GAPInfo.ManualDataRef.pathtoroot := DirectoriesLibrary("");
Copy link
Member

Choose a reason for hiding this comment

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

This variable is not used at all, why set it at all?

@markuspf
Copy link
Member Author

Mostly these things are leftovers from banging my head against how to build manuals and examples.

I am also not quite sure whether there is currently consensus on #1076 at all...

@fingolfin
Copy link
Member

@markuspf I see nothing controversial on #1076, what are you refering to?

@@ -33,6 +30,8 @@ WriteExamplesTst := function(directory)
output := OutputTextFile( Concatenation(directory, "/", chname), false );
SetPrintFormattingStatus( output, false );

# PrintTo will *overwrite* the file if it exists, making sure
# we don't concatenate the same test into a file multiple times
Copy link
Member

Choose a reason for hiding this comment

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

This comment is incorrect. It is it the false in the call to OutputTextFile which takes care of that. Other than that, PRINT_TO_STREAM and APPEND_TO_STREAM are doing exactly the same thing (see PR #1093). Note that the GAP manual even states that PrintTo and AppendTo for streams both append -- of course, if you think about it, they have no other choice, since that's how streams work -- there is no way to "delete" the content of a stream.

Copy link
Member Author

Choose a reason for hiding this comment

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

Orgh. Sorry, shows how much attention I paid reading the documentation (which I did), and remembering my code (which I obviously didn't).

@markuspf markuspf force-pushed the test-manualexamples branch from fa4d7f5 to bec76dd Compare January 19, 2017 12:07
@@ -10,7 +10,7 @@ matrix:
after_success:
- bash <(curl -s https://codecov.io/bash)
- os: linux
env: TEST_SUITE=testtravis CFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS="-fprofile-arcs"
env: TEST_SUITE=testmanuals CFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS="-fprofile-arcs"
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be an additional travis run? I.e. not replace the testtravis run on Linux.

@fingolfin
Copy link
Member

One of the test failures is fixed in master, another will be fixed by PR #1100. Might want to rebase once the latter is merged.

And of course @alex-konovalov mentioned an upcoming alternate implementation, looking forward to that, too :-).

@fingolfin
Copy link
Member

@markuspf BTW, how about replacing that tst/testmanuals/KEEP by a call to CreateDir (which is idempotent) in tst/testmanuals.g ?

@fingolfin
Copy link
Member

Also, the last test run for this died with this error on Travis:

Extracting manual examples...
Error, Record: '<rec>.ManualDataRef' must have an assigned value
not in any function at tst/testmanuals.g:14
you can 'return;' after assigning a value
brk> 

@markuspf markuspf force-pushed the test-manualexamples branch from bec76dd to 3e19ab0 Compare January 25, 2017 11:20
else
case $TEST_SUITE in
makemanuals)
if [[ $TRAVIS_OS_NAME = 'linux' ]]
Copy link
Member

Choose a reason for hiding this comment

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

Any particular reason for this check? We only run makemanuals on linux anyway, right?

then
make manuals
cat doc/*/make_manuals.out
if [ `cat doc/*/make_manuals.out | grep -c "manual.lab written"` != '3' ]
Copy link
Member

Choose a reason for hiding this comment

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

Why the use of cat, and not just grep rep -c "manual.lab written doc/*/make_manuals.out ?

(Oh wait, that's old code, OK.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know, but this must've been there before, copied and pasted through the centuries. I can change it though while I am at it.

for ch in tst/testmanuals/*.tst
do
COVNAME="coverage.`basename $ch .tst`"
sh bin/gap.sh -q --cover $COVNAME <<GAPInput
Copy link
Member

Choose a reason for hiding this comment

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

On my system with a new SSD, it takes 1.5 seconds to start GAP. Even if it's fully cached in RAM. I do not know how long it takes on Travis, but I wouldn't be surprised if it was slower there. We do this 80 times or so, hence just starting GAP that often costs us 2 minutes or more.

So I would really consider using a workspace here, like we do in the make targets.

Copy link
Member

Choose a reason for hiding this comment

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

Even better: You could move this call after the esac, and loop over all coverage* files in GAP. I.e. it would be the same code for the testmanuals code as for all the other testFOO targets.

done
cd bin/x86* ; gcov -o . ../../src/*
cd ../..
;;
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest moving these two commands after the esac. It's always the same -- and it doesn't hurt if we run it for the makemanuals target, too does it?

cd ../..
fi;

sh bin/gap.sh -q <<GAPInput
Copy link
Member

Choose a reason for hiding this comment

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

Oh wait, we call gap twice per iteration? Then it is 4 minutes :-).

Though perhaps we could move this second invocation out of the loop, turning it into a single invocation, where GAP loops over the coverage.*.tst files? This way, we turn ~80 GAP starts into a single one.

OutputJsonCoverage("coverage", "coverage.json");
for ch in tst/testmanuals/*.tst
do
COVNAME="coverage.`basename $ch .tst`"
Copy link
Member

Choose a reason for hiding this comment

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

wait, why the tst suffix? That would suggest the files are .tst files, which they are not, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just to clarify this is to remove the tst suffix from the chapterX.tst filename (which are .tst files) to make a filename for a coverage file which then is not a .tst file.

Copy link
Member

Choose a reason for hiding this comment

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

You are of course right, I misparsed this, sorry

@markuspf markuspf force-pushed the test-manualexamples branch from 315fe8d to 4727bf2 Compare January 25, 2017 19:54
@markuspf markuspf removed the do not merge PRs which are not yet ready to be merged (e.g. submitted for discussion, or test results) label Jan 25, 2017
@markuspf markuspf added this to the GAP 4.9.0 milestone Jan 25, 2017
@markuspf
Copy link
Member Author

This should be ready now. Test fails until #1106 is merged.

@markuspf markuspf force-pushed the test-manualexamples branch from 4727bf2 to 526885e Compare January 25, 2017 20:02
@@ -63,3 +63,7 @@

/tags
/src/TAGS
src/TAGS
Copy link
Member

Choose a reason for hiding this comment

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

I just find it strange that all paths above start with / and paths below without /, and we have both tags and tags.

@markuspf markuspf force-pushed the test-manualexamples branch from 526885e to 6177b24 Compare January 25, 2017 21:03
* Extracts the examples from the reference manual chapter by chapter
  into separate `.tst` files
* Runs each of the created `.tst` files in a separate GAP process
* Creates coverage reports, which are uploaded to codecov.io.
@markuspf markuspf force-pushed the test-manualexamples branch from 6177b24 to 421cf25 Compare January 26, 2017 21:16
@fingolfin fingolfin merged commit f51a365 into gap-system:master Feb 6, 2017
@markuspf markuspf deleted the test-manualexamples branch February 6, 2017 12:41
@olexandr-konovalov olexandr-konovalov added the release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes label Jan 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants