Testing mappyfile

There are two main objectives to testing mappyfile.

  1. Check that mappyfile can parse all the test Mapfiles in the test suite.

  2. Check that mappyfile can parse the Mapfile, pretty print it to a new file, run the tests on the new file, and check that the output is the same as the original.

The Mapfiles won’t be identical as comments will be stripped, and whitespace will change. They should however produce the same results. MapServer has a full set of regression tests - msautotest that includes 100s of Mapfiles. For example:

These have been downloaded and added to the /tests/sample_maps folder and are tested as part of the automated pytest test suite. Includes are not currently included - extension names of include files differ - sometimes .map and sometimes .include. In addition they are sometimes stored in an includes folder, and sometimes in a data folder. These includes are currently added to an ignore_list in the test_sample_maps.py test file.

A second test file test_msautotest.py can be pointed to a clone of the MapServer repository, and parses them, writes them to a new file, and then parses the new output. This is a good check that the mappyfile pretty-print output remains valid.

Running the Test Suite

The test suite can be run to check that the mappyfile outputs not only pass the mappyfile parsing and validation steps, but also pass being loaded by MapServer and run as part of msautotest. The steps below can be run on Windows using PowerShell. Note however that due to image output differences between Windows and the expected reference images generated by Linux there will be lots of failures.

C:\Python310\Scripts\virtualenv C:\VirtualEnvs\msautotest
pip install lxml
pip install future
pip install pytest


python python pymod/xmlvalidate.py -download_ogc_schemas

new-item -itemtype symboliclink -path . -name SCHEMAS_OPENGIS_NET -value $MSAUTOTEST_ROOT\SCHEMAS_OPENGIS_NET
# can add -v for verbose output to the command below
python.exe run_test.py

new-item -itemtype symboliclink -path . -name SCHEMAS_OPENGIS_NET -value $MSAUTOTEST_ROOT\SCHEMAS_OPENGIS_NET
python.exe run_test.py

# now run on mappyfile generated Mapfiles - error count should match
# switch to the copied output folder defined in test_msautotest.py
cd D:\GitHub\mapserver\msautotest_mappyfile\misc
new-item -itemtype symboliclink -path . -name SCHEMAS_OPENGIS_NET -value $MSAUTOTEST_ROOT\SCHEMAS_OPENGIS_NET
python.exe run_test.py