I created this ticket to share a potential bug identified in the management of MTS groovy tags.
We get an error when we try to run a groovy script that is not under the tree in which the main test file is located. This groovy tag has an attribute named "name" that defines the path to the groovy script.
For example, an error will be raised if you execute the following code:
groovy_Attenuator.run()
In the source code of MTS, I found a function in the \ src \ main \ java \ com \ devoteam \ srit \ xmlloader \ core \ operations \ basic \ OperationGroovy.java file named prepareScriptProperties that seems to be in charge of the management of this tag.
After studying this source code, I think that the current revision of MTS does not allow to define a path with .. or ./.
Here is the function that seems to be problematic :
/**
* generate a property name based on the groovy script filename and store
* the script instance in the map
*
* @param groovyFilename
* @param script
* @throws ExecutionException
*/
private void prepareScriptProperties(Runner runner, String groovyFilename, Script script) throws ExecutionException {
// the property name is prefixed by "groovy_" followed by the script filename
// without suffix
// ie if we load Toto.groovy, the script instance property will be groovy_Toto
int first = groovyFilename.lastIndexOf('/');
if (first == -1) {
first = 0;
} else if (first > 0) {
//remove last '/'
first += 1;
}
int last = groovyFilename.indexOf('.');
if (last >= first) {
String propertyName = MTSBinding.GROOVY_VAR_PREFIX + groovyFilename.substring(first, last);
injectedScripts.put(propertyName, script);
GlobalLogger.instance().getSessionLogger().debug(runner, TextEvent.Topic.CORE, "injecting " + propertyName + " object for script " + groovyFilename);
} else {
throw new ExecutionException("cannot load groovy script " + groovyFilename + " : invalid file name");
}
}
The consequence of this bug is that it is not possible to point a script that is not in the tree in which the test file is located.