Skip to content

Update the unit tests to use a full PG environment#726

Merged
pstaabp merged 13 commits into
openwebwork:developfrom
drgrice1:migration_to_test2_new
Oct 12, 2022
Merged

Update the unit tests to use a full PG environment#726
pstaabp merged 13 commits into
openwebwork:developfrom
drgrice1:migration_to_test2_new

Conversation

@drgrice1

Copy link
Copy Markdown
Member

This builds on #709 and #702. Since my reviews on #702 have not received any attention, consider this a replacement of that pull request. The commits from that pull request are contained in this one.

The main thing this does is improves the t/build_PG_envir.pl file to use the PG environment from #709 to create a complete translator environment for use in the unit tests. All of that will be needed for unit tests to properly work.

Also a unit test for testing the PGtikz.pl macro is added.

@drgrice1

Copy link
Copy Markdown
Member Author

Also note that this pull request is included in #724.

@pstaabp

pstaabp commented Sep 14, 2022

Copy link
Copy Markdown
Member

Want to point out that if your external programs are not the defaults in conf/pg_config.dist.yml to create a conf/pg_config.yml file with overrides. The new tikz test failed for me because my pdflatex is not in the standard location.

@pstaabp pstaabp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good.

@drgrice1

Copy link
Copy Markdown
Member Author

Yeah, the pg_config.dist.yml will need to be set correctly for your system for the new tikz test to work. Unfortunately, I don't think there is any way around that.

@drgrice1 drgrice1 force-pushed the migration_to_test2_new branch 11 times, most recently from 482cf5e to 0926355 Compare September 21, 2022 11:55
@drgrice1 drgrice1 force-pushed the migration_to_test2_new branch from 0926355 to 8dc909b Compare September 22, 2022 19:58
@pstaabp pstaabp mentioned this pull request Sep 26, 2022
3 tasks
@drgrice1 drgrice1 force-pushed the migration_to_test2_new branch 2 times, most recently from 1eda900 to 4199579 Compare October 5, 2022 22:33
drgrice1 and others added 11 commits October 8, 2022 05:41
Remove the ALWAYS_SHOW_HINT_PERMISSION_LEVEL and
ALWAYS_SHOW_SOLUTION_PERMISSION_LEVEL settings.  Whether hints and
solutions are shown is now determined by the front end.

The pg flag/variable $showHint has been removed.  The front end has
complete control on when hints are shown.  Not the problem author.

Also the options to use knowls for solutions and hints have been
removed.  Always use knowls for solutions and hints.

Showing the various pieces of debugging information for a problem is now
controlled with translation options.  The front end is responsible for
converting permissions into these debugging options.  The
VIEW_PROBLEM_DEBUGGING_INFO special pg environment variable was removed
and is one of these debugging options.

Many unnecessary PG environment variables have been removed.  One of
these is the session key.

Remove reduced scoring entirely from PG.  That is the responsibility of
the front end to implement.

Pg now has not dates and and no permissions.

The color.c file has been removed.  The method in that file has been
reimplemented in Chromatic.pm using perl.  It is perhaps a bit slower,
but not significantly in the scope of rendering a problem.  This can be
tested with the problems
Library/NAU/setGraphTheory/FindChromaticNumber.pg,
Library/NAU/setGraphTheory/FindRoomColor.pg, and
Library/NAU/setGraphTheory/RoomSchedule.pg
which happen to be all known problems that use the Chromatic module.

The image generator has been rewritten to remove the dvipng_align hack
and to allow the usage of sqlite for a database backend for storing
dvipng depths.

Note that PGalias no longer uses the course name, user login, set
number, and problem number for generating resource UUID's.  It now only
uses the problem seed, psvn, and problemUUID.  It is the caller's
responsibility of ensuring that problemUUID guarantees the necessary
uniqueness.
The t/macros/load_macros.t file tests that all macros load without
errors or warnings.

There is one macro that will not work in this test and it is skipped.
That is the answerDiscussion.pl macro.  It requires a file that is not
part of the PG distribution.  It also has invalid `defined(@array)`
calls.

Warnings found in other macro files were fixed.

The PG_module_list.pl macro was deleted.  That is clearly obsolete and
will not work.

There are also some tests added in t/pg_problems that test that
rendering with the WeBWorK::PG module works and demonstrate how to use
it in unit tests.
AppletObjects.pl macro caused by extending the Applet package in the
macro.  Instead of extending the Applet package, a derived package
(PGApplet) is created and used in the macro.  The GeogebraWebApplet
package needs to derive from the PGApplet package, and so it needs to be
moved to the macro.  Also, the Applet.pm package no longer derives from
the PGcore package.  It doesn't need to as it uses none of the PGcore
module methods.
The server really should not be checking urls in this way.  If an
invalid url is given, let the error come out in the browser.  This is
the correct way to deal with this.
Many subroutines are redefined in macros.

In addition if multiple WeBWorK::PG::Translator instances are created in
the same process, the safe compartment is not entirely isolated between
instances, and this causes redefine warnings if a macro is loaded in
both instances.  This is due to a memory leak somewhere and needs to be
fixed.
back to the original file in which the error occurred.
Squashed commits after messing up the rebase onto the latest develop branch.
Recreated and these are the commit messages rescued from that.

tableau.t
    PITA!  The circular references in MathObjects made
    the deep comparisons impossible, so all MathObjects
    were stringified for comparisons.

    WARN and DEBUG message sub redefinitions were removed.
    A "validator" and a stringify sub were added to get around
    some of the comparison issues.

    Organized into subtests.

math_objects_basics.t
    Convert `throws_ok` to the like/dies construct
    and the tests pass.
    Arranged sections in subtests

Three test files migrated from Test::More to Test2 without modification
    (other than moving the environment setup from the script to Test::PG)

This expands on the original t/README.md on the details of testing.

t/context
    Minor changes to migrate tests in t/context from Test::More to Test2
    There were few tests in these files.

    toltype_digits.t organized into subtests by topic

    Use the Test::PG environment with Test2

    Find that the original test produced unexpected results
    and the tests that expose the incorrect behaviour have
    been wrapped in a TODO block

Added unit tests for Units.pm
    Tests to validate the correctness of openwebwork#677
    Unit tests for Units.pm electron volts
    Tests for parserNumberWithUnits.pl with basic energy conversions

    Adding a Test::PG module in t/lib/ to take the place of t/build_PG_envir.pl
Convert math_objects/factorial.t to using the Test2 framework
Update the t/README.md to the new usage of Test2 and the boilerplate Test::PG module
removed the execute permission from tableau.t
@drgrice1 drgrice1 force-pushed the migration_to_test2_new branch from 4199579 to 66952a4 Compare October 8, 2022 10:42
@pstaabp pstaabp merged commit 94507b8 into openwebwork:develop Oct 12, 2022
@drgrice1 drgrice1 deleted the migration_to_test2_new branch October 12, 2022 19:39
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.

4 participants