More logging and be failfast around mtaYamlFile

- don't log a message and continue when it is clear that we cannot succeed
    together with error raised later during attempt not parse a non-existing
    file
  - More log output in order to clarify what happens with mta.yaml
This commit is contained in:
Marcus Holl
2018-11-13 09:23:26 +01:00
parent 9c27fbadf1
commit a84d91f6bf
2 changed files with 9 additions and 5 deletions
+5 -4
View File
@@ -40,7 +40,7 @@ public class MtaBuildTest extends BasePiperTest {
@Before
void init() {
helper.registerAllowedMethod('fileExists', [String], { s -> false })
helper.registerAllowedMethod('fileExists', [String], { s -> s == 'mta.yaml' })
helper.registerAllowedMethod('sh', [Map], { Map m -> getVersionWithoutEnvVars(m) })
binding.setVariable('PATH', '/usr/bin')
@@ -90,9 +90,10 @@ public class MtaBuildTest extends BasePiperTest {
@Test
void noMtaPresentTest() {
jryr.registerYaml('mta.yaml', { throw new FileNotFoundException() })
thrown.expect(FileNotFoundException)
helper.registerAllowedMethod('fileExists', [String], { false })
thrown.expect(AbortException)
thrown.expectMessage('\'mta.yaml\' not found in project sources and \'applicationName\' not provided as parameter ' +
'- cannot generate \'mta.yaml\' file.')
jsr.step.mtaBuild(script: nullScript, buildTarget: 'NEO')
}
+4 -1
View File
@@ -51,11 +51,14 @@ void call(Map parameters = [:]) {
if (!fileExists(mtaYamlName)) {
if (!applicationName) {
echo "'applicationName' not provided as parameter - will not try to generate ${mtaYamlName} file"
error "'${mtaYamlName}' not found in project sources and 'applicationName' not provided as parameter - cannot generate '${mtaYamlName}' file."
} else {
echo "[INFO] '${mtaYamlName}' file not found in project sources, but application name provided as parameter - generating '${mtaYamlName}' file."
MtaUtils mtaUtils = new MtaUtils(this)
mtaUtils.generateMtaDescriptorFromPackageJson("package.json", mtaYamlName, applicationName)
}
} else {
echo "[INFO] '${mtaYamlName}' file found in project sources."
}
def mtaYaml = readYaml file: mtaYamlName