04.04 - Context parameters

Squash-TA framework 1.8.0 introduce the context parameters feature. The idea is:

    • First: to provide parameters (list of key/value) at execution through json data ( at script or at global level )

{

"test" : [{

"script" : "pathToMyscript1",

"param" : { // Script context parameters

"my_cuf" : "value1",

"property2" : "value2"

}

}

],

"param" : { // Global context parameters

"property2" : "value13",

"property6" : "value14"

}

}

    • Second: to transform the parameters as a TA resource of type properties.

      • For script context parameters the resource is available in the test under the name context_script_params

      • For global context parameters the resource is available in the test under the name context_global_params

  • Third: to use the created TA resources in test scripts through from file to file (using param) converter

    • Created TA resource could be used in the converter USING clause like other classical resources with the same rule

In the sample below, in processedCommandFile ${my_cuf} is replaced by "value1"

{

"test" : [{

"script" : "pathToMyscript1",

"param" : {

"my_cuf" : "value1",

"property2" : "value2"

}

}

],

"param" : {

"property2" : "value13",

"property6" : "value14"

}

}

_________________________________________________________________________________________________________________

DEFINE $(monShell.sh -param1=${my_cuf}) AS commandFile

CONVERT commandFile TO file(param) USING context_script_params AS processedCommandFile

CONVERT processedCommandFile TO query.shell (query) AS commandLine

EXECUTE local WITH commandLine AS result

context_script_params and context_global_params could be used together. The priority rules are the classical rules of the file to file (param) converter. In the sample below, if simple-script.sah contains ${property2}, then it would be replace by the converter by value2:

{

"test" : [{

"script" : "pathToMyscript1",

"param" : {

"my_cuf" : "value1",

"property2" : "value2"

}

}

],

"param" : {

"property2" : "value13",

"property6" : "value14"

}

}

_________________________________________________________________________________________________________________

LOAD sahi/placeholder.properties AS placeholder.file

CONVERT placeholder.file TO properties(structured) AS placeholder.properties

LOAD sahi/main/simple-script.sah AS sahiFile

CONVERT sahiFile TO file(param) USING placeholder.properties, context_global_params, context_script_params AS processedSahiFile

CONVERT processedSahiFile TO script.sahi(script) AS suite

Note: context_script_params and context_global_params are now reserved context TA resource name. The framework doesn't prevent you to define your own TA resource with those context name, BUT in this case they hide context parameters. In the sample below context_script_params correspond to sample.properties.

LOAD sample.properties AS sample.file

CONVERT sample.file TO properties(structured) AS context_script_params

LOAD sahi/main/simple-script.sah AS sahiFile

CONVERT sahiFile TO file(param) USING context_script_params AS processedSahiFile

CONVERT processedSahiFile TO script.sahi(script) AS suite