Squirt 3.21
HspScript Class Reference

HspScript is a class for the CTRL script actions. More...

Public Member Functions

public HspScript ()
 A default constructor.
 
public void setScript (const string &script)
 The Function sets the content of a CTRL script. More...
 
public string getScript ()
 The function returns the content of a CTRL script. More...
 
public bool isEmpty ()
 The function checks if a CTRL script is empty. More...
 
public string getFileName ()
 The function returns the file name of a CTRL script. More...
 
public string getFilePath ()
 The function returns the relative path to a CTRL script. More...
 
public string getFileRelPath ()
 The function returns the relative path to a CTRL script in a native format. More...
 
public int setFilePath (const string &path)
 The function sets a path to this CTRL script. More...
 
public int makeScriptFromTemlate (const string &templateRelPath)
 The function creates a new CTRL script from the given template. More...
 
public void makeFileHeader ()
 The function creates a mini header for a CTRL script. More...
 
public int replaceKey (const string &key, const string &value)
 The function replaces given keys by value in a CTRL script. More...
 
public bool isPartOf (const string &scriptType)
 The function checks the CTRL script part of the given relative path. More...
 
public int trimTrailingSpace ()
 The function removes all trailing spaces from the lines in a CTRL script. More...
 
public int trimLeadingSpace ()
 The function removes all leading spaces from the lines in a CTRL script. More...
 
public string getExampleRelPath ()
 The function returns the relative path to the example of the specified CTRL script. More...
 
public string getExampleFullPath ()
 The function returns the full path to the example of the specified CTRL script. More...
 
public bool exampleExist ()
 The function checks if an example for a CTRL script exists. More...
 
public int createExample ()
 The function creates an example for a library. More...
 
public string getUnitTestRelPath ()
 The function returns the relative path to the unit test of the specified CTRL script. More...
 
public string getUnitTestFullPath ()
 The function returns the full path to the example of the specified script. More...
 
public bool unitTestExist ()
 The function checks if a uni test exists. More...
 
public int createUnitTest ()
 The function creates a unit test for the library. More...
 
public string getGuiTestRelPath ()
 Returns the default GUI test directory for the current panel file. More...
 
public dyn_string getGuiTestFullPaths ()
 Returns all GUI test script paths for the current panel. More...
 
public bool guiTestExist ()
 Checks whether at least one GUI test exists for the current panel. More...
 
public int startExample (string relPath="", string addOptions="")
 The function starts an example for the library. More...
 
public int startUnitTest (string relPath="", string addOptions="")
 The function starts a unit test for the library. More...
 
public int startGuiTests (string relPath="", string addOptions="")
 Starts one or all GUI tests for the current panel. More...
 
private int startGuiTest (string relPath, string addOptions)
 Starts a single GUI test script. More...
 
public string getCoverageReportPath ()
 The function returns the relative path to the coverage report. More...
 
public void showErrMsg (const anytype &msg)
 The function shows a message in the CTRL script editor. More...
 
public bool isNewFile ()
 The function checks if a CTRL script file is empty (0 byte). More...
 
public bool isRunning (const string path)
 The function checks if the given script is running. More...
 
public int stopRunningScript (const string path)
 The function stops the given script. More...
 

Static Public Member Functions

static public string getDelim (int spaces=0)
 The function returns a line delimiter with a fixed length. More...
 

Public Attributes

public bool guiTest
 TRUE when script execution should use GUI test mode (UI manager).
 

Protected Member Functions

protected string stripFromProjPath (string fullPath, const string &relPath)
 The function returns a relative path. More...
 
protected string fileNameToClassName ()
 The function returns the CTRL class name by the file name. More...
 
protected int start (const string &relPath, const string addOptions="", bool doCoverage=FALSE)
 The function starts the system call with the given script path and options. More...
 
protected void addScriptToRunning (const string &path) synchronized(mutex)
 The function adds a CTRL script and its PID to a list of running scripts. More...
 
protected void removeScriptFromRunning (const string &path) synchronized(mutex)
 The function removes a CTRL script from the list of running scripts. More...
 
protected void updateScriptState (string relPath)
 The function updates the script state in the GEDI project view. More...
 

Detailed Description

HspScript is a class for the CTRL script actions.

Member Function Documentation

◆ addScriptToRunning()

protected void HspScript::addScriptToRunning ( const string &  path)
protected

The function adds a CTRL script and its PID to a list of running scripts.

Parameters
pathThe given script full path.

◆ createExample()

public int HspScript::createExample ( )

The function creates an example for a library.

Returns
int errorCode The function returns 0 if it was successfully executed and otherwise an error code. Error code.
Value Description
0 Success
-1 An example cannot be created since it already exists.
-2 An example cannot be created since this script is not a library.
-3 An example cannot be created since the user does not have the neccessary permission.

◆ createUnitTest()

public int HspScript::createUnitTest ( )

The function creates a unit test for the library.

Returns
int errorCode The function returns 0 if it was successfully executed and otherwise an error code. Error code.
Value Description
0 Success
-1 A unit test cannot be created since it already exists.
-2 A unit test cannot be created since the script is not a library.
-3 A unit test cannot be created since the user does not have the neccessary permission.

◆ exampleExist()

public bool HspScript::exampleExist ( )

The function checks if an example for a CTRL script exists.

Returns
bool example The function returns TRUE if an example exists and otherwise FALSE.

◆ fileNameToClassName()

protected string HspScript::fileNameToClassName ( )
protected

The function returns the CTRL class name by the file name.

The function removes invalid chars (only alphanumeric are allowed).

Returns
The changed string.

◆ getCoverageReportPath()

public string HspScript::getCoverageReportPath ( )

The function returns the relative path to the coverage report.

Returns
string path The path to the coverage report as a string.

◆ getDelim()

static public string HspScript::getDelim ( int  spaces = 0)
static

The function returns a line delimiter with a fixed length.

Parameters
spacesSpaces on the left of the delimiter.
Returns
string delimeter The line delimiter.

◆ getExampleFullPath()

public string HspScript::getExampleFullPath ( )

The function returns the full path to the example of the specified CTRL script.

Returns
string path The full path to the example.
Exceptions
Emptystring- if an example does not exist.

◆ getExampleRelPath()

public string HspScript::getExampleRelPath ( )

The function returns the relative path to the example of the specified CTRL script.

The path is returned in unix format.

Note
The function does not check if the given CTRL script or example script exists.
Returns
string path The relative path to the example script.

◆ getFileName()

public string HspScript::getFileName ( )

The function returns the file name of a CTRL script.

Returns
string file A CTRL script file name with an extension.

◆ getFilePath()

public string HspScript::getFilePath ( )

The function returns the relative path to a CTRL script.

The absolute path is cut and the relative path is returned.

Returns
string path The full path to a script.

◆ getFileRelPath()

public string HspScript::getFileRelPath ( )

The function returns the relative path to a CTRL script in a native format.

The path is relative to the project.

Returns
string path A relative path to a CTRL script.

◆ getGuiTestFullPaths()

public dyn_string HspScript::getGuiTestFullPaths ( )

Returns all GUI test script paths for the current panel.

Returns
Full paths of discovered GUI test scripts.

◆ getGuiTestRelPath()

public string HspScript::getGuiTestRelPath ( )

Returns the default GUI test directory for the current panel file.

Returns
Relative GUI test path ending with slash.

◆ getScript()

public string HspScript::getScript ( )

The function returns the content of a CTRL script.

Warning
The script must not be parsable.
Returns
string script Content of a script.

◆ getUnitTestFullPath()

public string HspScript::getUnitTestFullPath ( )

The function returns the full path to the example of the specified script.

Returns
string path The full path to the example.
Exceptions
Emptystring - if an example does not exist.

◆ getUnitTestRelPath()

public string HspScript::getUnitTestRelPath ( )

The function returns the relative path to the unit test of the specified CTRL script.

The Path is returned in unix format.

Note
The function does not check if the given CTRL script or test script exists.
Returns
string path The relative path to the test script.

◆ guiTestExist()

public bool HspScript::guiTestExist ( )

Checks whether at least one GUI test exists for the current panel.

Returns
TRUE if GUI test scripts are available, otherwise FALSE.

◆ isEmpty()

public bool HspScript::isEmpty ( )

The function checks if a CTRL script is empty.

Returns
bool script Returns TRUE when a CTRL script is empty and otherwise FALSE.

◆ isNewFile()

public bool HspScript::isNewFile ( )

The function checks if a CTRL script file is empty (0 byte).

Returns
The function returns TRUE when it is empty and otherwise FALSE.

◆ isPartOf()

public bool HspScript::isPartOf ( const string &  scriptType)

The function checks the CTRL script part of the given relative path.

Parameters
scriptTypeScript type. The relative path such as:
  • SCRIPTS_REL_PATH
  • LIBS_REL_PATH
Returns
bool path The function returns TRUE when the path matches the relative path and otherwise FALSE.

◆ isRunning()

public bool HspScript::isRunning ( const string  path)

The function checks if the given script is running.

Parameters
pathThe script path (could be a relative or a full path).
Returns
TRUE when a script is running or the script path is empty and otherwise FALSE.

◆ makeFileHeader()

public void HspScript::makeFileHeader ( )

The function creates a mini header for a CTRL script.

The header is used if a template is not found. See also makeScriptFromTemplate()

◆ makeScriptFromTemlate()

public int HspScript::makeScriptFromTemlate ( const string &  templateRelPath)

The function creates a new CTRL script from the given template.

Parameters
templateRelPathA relative (or full) path to the template.
Returns
int Error code. The function returns 0 when it was successfully executed and otherwise -1.

◆ removeScriptFromRunning()

protected void HspScript::removeScriptFromRunning ( const string &  path)
protected

The function removes a CTRL script from the list of running scripts.

Parameters
pathThe path of the script to be removed.

◆ replaceKey()

public int HspScript::replaceKey ( const string &  key,
const string &  value 
)

The function replaces given keys by value in a CTRL script.

The function only changes the content of a cTRL script. The function does not save the script.

Parameters
keyKey for the search.
valueValue to be replaced.
Returns
int Count Count of replaced keys.

◆ setFilePath()

public int HspScript::setFilePath ( const string &  path)

The function sets a path to this CTRL script.

Parameters
pathThe full path to this CTRL script.
Returns
int val The function returns 0 if it was successfully executed and otherwise an errorCode: Error code:
Value Description
0 Success
-1 An invalid path

◆ setScript()

public void HspScript::setScript ( const string &  script)

The Function sets the content of a CTRL script.

The function does not save the script. It only sets the content in this object. The script must not be parsable.

Parameters
scriptScript content.

◆ showErrMsg()

public void HspScript::showErrMsg ( const anytype &  msg)

The function shows a message in the CTRL script editor.

Parameters
msgThe Message to be shown.

◆ start()

protected int HspScript::start ( const string &  relPath,
const string  addOptions = "",
bool  doCoverage = FALSE 
)
protected

The function starts the system call with the given script path and options.

The system call contains a WCCOActrl.exe, 'given script path' and 'given options'.

Parameters
relPathRelative or full script path to start.
addOptionsAdditional command-line options.
doCoverageEnables coverage options when TRUE.
Returns
int rc The function returns 0 on success. The function returns -1 if no argument was specified, a new process could not be created or if the started process was not finished normally.

◆ startExample()

public int HspScript::startExample ( string  relPath = "",
string  addOptions = "" 
)

The function starts an example for the library.

Parameters
relPathThe path to the example script file. If the path is not specified, it will be defined by using the getExampleRelPath() function.
addOptionsThe options you want to start your example with.
Returns
int errorCode The function returns 0 if it was successfully executed and otherwise an error code. Error code.
Value Description
0 Success
-1 An example cannot be started since a new process could not be created.

◆ startGuiTest()

private int HspScript::startGuiTest ( string  relPath,
string  addOptions 
)

Starts a single GUI test script.

Parameters
relPathRelative or full path to GUI test script.
addOptionsAdditional process options.
Returns
0 on success, otherwise an error code.

◆ startGuiTests()

public int HspScript::startGuiTests ( string  relPath = "",
string  addOptions = "" 
)

Starts one or all GUI tests for the current panel.

Parameters
relPathOptional relative/full path to one GUI test script.
addOptionsAdditional process options.
Returns
0 on success, otherwise error code from startGuiTest().

◆ startUnitTest()

public int HspScript::startUnitTest ( string  relPath = "",
string  addOptions = "" 
)

The function starts a unit test for the library.

Parameters
relPathThe path to the unit test script file. If the path is not specified, it will be defined by using the function getUnitTestRelPath().
addOptionsThe options you want to start your unit test with.
Returns
int errorCode The function returns 0 if it was successfully executed and otherwise an error code. Error code.
Value Description
0 Success
-1 A unit test cannot be started since a new process could not be created.

◆ stopRunningScript()

public int HspScript::stopRunningScript ( const string  path)

The function stops the given script.

Parameters
pathThe script path (can be a relative or a full path).
Returns
Return Error code. Error code.
Value Description
0 Successful.
-1 The script cannot be stopped. Its path is empty or it is not running.

◆ stripFromProjPath()

protected string HspScript::stripFromProjPath ( string  fullPath,
const string &  relPath 
)
protected

The function returns a relative path.

A full path must be specified as a parameter. The function cuts the relative path out of the full path.

Parameters
fullPathThe full path to be cut.
relPathThe relative path.
Returns
The function returns a relative path.

◆ trimLeadingSpace()

public int HspScript::trimLeadingSpace ( )

The function removes all leading spaces from the lines in a CTRL script.

Returns
int count The count of changed lines.

◆ trimTrailingSpace()

public int HspScript::trimTrailingSpace ( )

The function removes all trailing spaces from the lines in a CTRL script.

Returns
int lines The function returns the count of changed lines.

◆ unitTestExist()

public bool HspScript::unitTestExist ( )

The function checks if a uni test exists.

Returns
bool test Returns TRUE when the test exists and otherwise FALSE.

◆ updateScriptState()

protected void HspScript::updateScriptState ( string  relPath)
protected

The function updates the script state in the GEDI project view.

Parameters
relPathThe path of the script to be updated.

The documentation for this class was generated from the following file: