Script line number tracking, bug fix in cmd reading
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
80d10d7d85
commit
1a207c8100
@ -1,3 +1,11 @@
|
|||||||
|
## Version 1.2.6
|
||||||
|
|
||||||
|
* in script command failure report improved
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
|
||||||
|
* command line reading now succeed to parse last argument if it is a string
|
||||||
|
|
||||||
## Version 1.1.0
|
## Version 1.1.0
|
||||||
|
|
||||||
* Parsing quoted string as one argument
|
* Parsing quoted string as one argument
|
||||||
|
@ -98,8 +98,8 @@ public class GCLCConstants {
|
|||||||
inString = startIndex == index - 1;
|
inString = startIndex == index - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final String arg = cmd.substring(startIndex, cmd.length());
|
if (startIndex < cmd.length()) {
|
||||||
if (!arg.isEmpty()) {
|
final String arg = cmd.substring(startIndex, cmd.length());
|
||||||
args.add(arg);
|
args.add(arg);
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
|
@ -92,7 +92,9 @@ public class ScriptExecution extends Command {
|
|||||||
for (int i = 1; i < args.length; i++) {
|
for (int i = 1; i < args.length; i++) {
|
||||||
params[i - 1] = args[i];
|
params[i - 1] = args[i];
|
||||||
}
|
}
|
||||||
|
int lineNo = -1;
|
||||||
while ((cmd = reader.readLine()) != null) {
|
while ((cmd = reader.readLine()) != null) {
|
||||||
|
lineNo++;
|
||||||
if (cmd.startsWith(" ") || cmd.startsWith("\t")) { //$NON-NLS-1$ //$NON-NLS-2$
|
if (cmd.startsWith(" ") || cmd.startsWith("\t")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
reader.close();
|
reader.close();
|
||||||
fReader.close();
|
fReader.close();
|
||||||
@ -106,7 +108,17 @@ public class ScriptExecution extends Command {
|
|||||||
String cmdLine = MessageFormat.format(cmd, params);
|
String cmdLine = MessageFormat.format(cmd, params);
|
||||||
List<String> ps = GCLCConstants.splitCommand(cmdLine);
|
List<String> ps = GCLCConstants.splitCommand(cmdLine);
|
||||||
String command = ps.remove(0);
|
String command = ps.remove(0);
|
||||||
|
try {
|
||||||
application.executeSub(command, ps.toArray(new String[0]));
|
application.executeSub(command, ps.toArray(new String[0]));
|
||||||
|
} catch (CommandRunException e) {
|
||||||
|
// TODO: handle exception
|
||||||
|
throw new CommandRunException(
|
||||||
|
CommandRunExceptionType.EXECUTION,
|
||||||
|
MessageFormat.format(
|
||||||
|
"The script could not complete due to command failure at line {0} ({1})",
|
||||||
|
lineNo, e.getLocalizedMessage()),
|
||||||
|
e, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (CommandParsingException e) {
|
} catch (CommandParsingException e) {
|
||||||
throw new CommandRunException("Invalid command in script (" + //$NON-NLS-1$
|
throw new CommandRunException("Invalid command in script (" + //$NON-NLS-1$
|
||||||
|
@ -129,6 +129,19 @@ public class GCLCConstantsTest {
|
|||||||
assertTrue(res.get(2).equals("some"));
|
assertTrue(res.get(2).equals("some"));
|
||||||
assertTrue(res.get(3).equals("arguments"));
|
assertTrue(res.get(3).equals("arguments"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
res = GCLCConstants
|
||||||
|
.splitCommand("aCommand with \"some arguments\"");
|
||||||
|
} catch (CommandParsingException e) {
|
||||||
|
fail("Unable to parse command ending with string argument " + //$NON-NLS-1$
|
||||||
|
e.getLocalizedMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
assertTrue(res.size() == 3);
|
||||||
|
assertTrue(res.get(0).equals("aCommand"));
|
||||||
|
assertTrue(res.get(1).equals("with"));
|
||||||
|
assertTrue(res.get(2).equals("some arguments"));
|
||||||
|
|
||||||
// Wrong lines?
|
// Wrong lines?
|
||||||
try {
|
try {
|
||||||
res = GCLCConstants
|
res = GCLCConstants
|
||||||
|
Loading…
Reference in New Issue
Block a user