Explaining SASUnit setup script - HMS-Analytical-Software/SASUnit GitHub Wiki
This new script shall facilitate the process of getting SASUnit running. Prior to version 2.1 you had to update multiple files to get SASUnit running. Now there is only one script that you need to adapt and this one creates all the start scripts that were formerly delivered with SASUnit. Short video showing the setup process
The script that you formerly needed to adjust are no longer shipped with SASUnit. Now you can use the new setup script.
You always have a triplet of files:
sasunit.setup.9.4.cmd: This is the core script file that will create all starting scripts.
sasunit.setup.9.4.en.cmd: Will create script files using english as SASUnit language.
sasunit.setup.9.4.de.cmd: Will create script files using german as SASUnit language.
This represents the script under Windows
If you are running SASUnit thne the triplest has then ending .sh.
And there a second triplet with asIs in the name that uses the traditionell folderstructure.
The ones mentioned above use the new folder structure we impemented.
We decided to rework the folder structure. Up to now the folder structure looks like this:
../example/doc/sasunit/en/doc/<HTML Report files>
/log/<log files of test scenarios>
<files of test data base>
<log file of SASUnit test suite>
The new structure is as follows:
../example/en/doc/<HTML Report files>
/logs/<log file of SASUnit test suite>
/scn_logs/<log files of test scenarios>
/testdb/<files of test data base>
This new folder structure was necessary to split content into etc, opt, var under linux. So there was a need to separate things.
You can take a look at the whole files in the repository.
Here I will outline the file sasunit.setup.9.4.cmd:
- Check if a language was given and if not then use 'en' as language
- Set environment variables for calling SAS
- Set environment variables to configure SASUnit
Here is legal stuff and check for language parameter:
@echo off
REM This file is part of SASUnit, the Unit testing framework for SAS(R) programs.
REM For copyright information and terms of usage under the GPL license see included file readme.txt
REM or https://sourceforge.net/p/sasunit/wiki/readme/.
cd ..
if /i "%~1" == "" (SET SASUNIT_LANGUAGE=en) else (SET SASUNIT_LANGUAGE=%1)
These variables are needed to find and start SAS
REM --------------------------------------------------------------------------------
REM --- EnvVars for SAS Configuration ----------------------------------------------
SET SASUNIT_HOST_OS=windows
SET SASUNIT_HOST_ENCODING=PCOEM850
SET SASUNIT_SAS_VERSION=9.4
SET SASUNIT_SASPATH=C:\Program Files\SASHome\SASFoundation\%SASUNIT_SAS_VERSION%
SET SASUNIT_SAS_EXE=%SASUNIT_SASPATH%\sas.exe
SET SASUNIT_SAS_CFG=%SASUNIT_SASPATH%\nls\%SASUNIT_LANGUAGE%\sasv9.cfg
Now let's configure SASUnit
REM --------------------------------------------------------------------------------
REM --- EnvVars for SAS Unit Configuration -----------------------------------------
SET SASUNIT_ROOT=c:\projects\sasunit
SET SASUNIT_PROJECTROOT=c:\projects\sasunit\example
SET SASUNIT_TESTDB_PATH=%SASUNIT_PROJECTROOT%\%SASUNIT_LANGUAGE%\testdb
SET SASUNIT_LOG_PATH=%SASUNIT_PROJECTROOT%\%SASUNIT_LANGUAGE%\logs
SET SASUNIT_SCN_LOG_PATH=%SASUNIT_PROJECTROOT%\%SASUNIT_LANGUAGE%\scn_logs
SET SASUNIT_REPORT_PATH=%SASUNIT_PROJECTROOT%\%SASUNIT_LANGUAGE%\doc
SET SASUNIT_RUNALL=%SASUNIT_PROJECTROOT%\saspgm\run_all.sas
SET SASUNIT_LOG_LEVEL=INFO
SET SASUNIT_SCN_LOG_LEVEL=INFO
Explaining the variables
-
SASUNIT_ROOT:
Points to the root folder of SASUnit. This folder must contain the folders resources and saspgm. -
SASUNIT_PROJECTROOT:
Is the base folder of your project you want to test with SASUnit. The setup scripts interpret this folder as a working folder and expects all files (including your programs to test) inside. We will remove this restrictions in the future. You can still configure SASUnit to work accordingly see Issue 20. There we outlined a work around with minimal effort. -
SASUNIT_TESTDB_PATH:
Points to the folder were SASUnit stores the test database -
SASUNIT_LOG_PATH:
Points to the folder were SASUnit stores the log files of the test suite -
SASUNIT_SCN_LOG_PATH:
Points to the folder were SASUnit stores the log files of all test scenarios -
SASUNIT_REPORT_PATH:
Points to the folder were SASUnit stores the test documentation -
SASUNIT_RUNALL:
Points to the program contains all test scenarios -
SASUNIT_LOG_LEVEL:
Logging level for the test suite (TRACE, DEBUG, INFO, WARN, ERROR, FATAL) -
SASUNIT_SCN_LOG_LEVEL:
Logging level for the test suite
Print all variables with their values when running. Just to see what has been set.
echo.
echo --- EnvVars for SAS Configuration ----------------------------------------------
echo Operating system = %SASUNIT_HOST_OS%
echo Host OS encoding = %SASUNIT_HOST_ENCODING%
echo SAS Version = %SASUNIT_SAS_VERSION%
echo SAS Installation Path = %SASUNIT_SASPATH%
echo SAS Executable = %SASUNIT_SAS_EXE%
echo SAS Config File = %SASUNIT_SAS_CFG%
echo --- EnvVars for SAS Unit Configuration -----------------------------------------
echo SASUnit root path = %SASUNIT_ROOT%
echo Project root Path = %SASUNIT_PROJECTROOT%
echo Path to SASUnit test database = %SASUNIT_TESTDB_PATH%
echo Path to SASUnit log files = %SASUNIT_LOG_PATH%
echo Path to SASUnit scenario log files = %SASUNIT_SCN_LOG_PATH%
echo Path to SASUnit documentation = %SASUNIT_REPORT_PATH%
echo Name and path of run_all program = %SASUNIT_RUNALL%
echo Logging level for SASUnit Suite = %SASUNIT_LOG_LEVEL%
echo logging Level for Scenarios = %SASUNIT_SCN_LOG_LEVEL%
echo --------------------------------------------------------------------------------
echo.
Now use provided variables to call SAS with a program to create all script files
echo "Creating script files for starting SASUnit ..."
"%SASUNIT_SAS_EXE%" -CONFIG "%SASUNIT_SAS_CFG%" -no$syntaxcheck -noovp -nosplash
-log "bin/sasunit.setup.%SASUNIT_SAS_VERSION%.%SASUNIT_LANGUAGE%.log"
-sysin "%SASUNIT_ROOT%/saspgm/sasunit/runsasunitsetup.sas"
And at the end the obligatory error check
if %ERRORLEVEL%==0 goto normalexit
@echo.
@echo Exit code: %ERRORLEVEL%
@echo.
if %ERRORLEVEL%==1 @echo SAS ended with warnings. Review run_all.log for details.
if %ERRORLEVEL%==2 @echo SAS ended with errors! Check run_all.log for details!
@echo.
pause
:normalexit
You need to change where SAS is located (change values in bold):
REM -------------------------------------------------------------------------------- REM --- EnvVars for SAS Configuration ---------------------------------------------- SET SASUNIT_HOST_OS=windows SET SASUNIT_HOST_ENCODING=PCOEM850 SET SASUNIT_SAS_VERSION=9.4 SET SASUNIT_SASPATH=C:\Program Files\SASHome\SASFoundation\%SASUNIT_SAS_VERSION% SET SASUNIT_SAS_EXE=%SASUNIT_SASPATH%\sas.exe SET SASUNIT_SAS_CFG=%SASUNIT_SASPATH%\nls\%SASUNIT_LANGUAGE%\sasv9.cfg
Then you need to adjust you SASUnit setup (change values in bold):
REM -------------------------------------------------------------------------------- REM --- EnvVars for SAS Unit Configuration ----------------------------------------- SET SASUNIT_ROOT=c:\projects\sasunit SET SASUNIT_PROJECTROOT=c:\projects\sasunit\example SET SASUNIT_TESTDB_PATH=%SASUNIT_PROJECTROOT%\%SASUNIT_LANGUAGE%\testdb SET SASUNIT_LOG_PATH=%SASUNIT_PROJECTROOT%\%SASUNIT_LANGUAGE%\logs SET SASUNIT_SCN_LOG_PATH=%SASUNIT_PROJECTROOT%\%SASUNIT_LANGUAGE%\scn_logs SET SASUNIT_REPORT_PATH=%SASUNIT_PROJECTROOT%\%SASUNIT_LANGUAGE%\doc SET SASUNIT_RUNALL=%SASUNIT_PROJECTROOT%\saspgm\run_all.sas SET SASUNIT_LOG_LEVEL=INFO SET SASUNIT_SCN_LOG_LEVEL=INFO
After running the setup script in your preferred langauge you will find the script files under sasunit/example/bin. There you have different versions of script files generated by the setup script.
The naming convention is as follows: sasunit.<SASVersion>.<OS>.<language>.<function>.<shell extension>
Filename | Function |
---|---|
sasunit.<SASVersion>.<OS>.<Language>.cfg | Configuration file for SASUnit test suite and scenarios |
sasunit.<SASVersion>.<OS>.<Language>.debug.cmd | Run SASUnit suite and scenarios with verbose logs to debug errors |
sasunit.<SASVersion>.<OS>.<Language>.fast.cmd | Run SASUnit suite and scenarios with minimal functionality. No statement covearge, no program documentatio, no call hierarchy modified tests only |
sasunit.<SASVersion>.<OS>.<Language>.full.cmd | Run SASUnit suite and scenarios with all functionality. modified tests only |
sasunit.<SASVersion>.<OS>.<Language>.overwrite.fast.cmd | Run SASUnit suite and scenarios with minimal functionality. No statement covearge, no program documentatio, no call hierarchy |
sasunit.<SASVersion>.<OS>.<Language>.overwrite.full.cmd | Run SASUnit suite and scenarios with all functionality. |
sasunit.<SASVersion>.<OS>.<Language>.reports_only.cmd | Creates SASUnit documentation without running scenarios. |
sasunit.<SASVersion>.<OS>.<Language>.trace.cmd | Run SASUnit suite and scenarios with maximum messages in the logs to debug really hidden errors |