Commit e577f32e authored by Florian Hölzl's avatar Florian Hölzl
Browse files

fixed smoke tests of gcc tool chain

refs 727
parent d55c78ac
......@@ -73,4 +73,10 @@ public class GCCRunner extends GCCToolChainRunnerBase {
int startOfVersioningInfo = helpMessage.indexOf("gcc version ");
return helpMessage.substring(startOfVersioningInfo + 12, startOfVersioningInfo + 17);
}
/** {@inheritDoc} */
@Override
protected boolean useErrorOutputForVersion() {
return true;
}
}
......@@ -45,20 +45,28 @@ public abstract class GCCToolChainRunnerBase extends SimpleToolRunnerBase<File>
/** {@inheritDoc} */
@Override
public String testToolAvailability() {
String toolCmd = "which " + getToolCommand() + " && " + getToolCommand();
Pair<String, String> outputs = smokeToolRun(toolCmd, "-v");
if(outputs != null && outputs.getSecond().length() > 0) {
String helpMessage = outputs.getSecond();
String whichOutput = "/" + getToolCommand() + "\n";
int endOfWhichLocation = helpMessage.indexOf(whichOutput) + whichOutput.length();
String whichLocation = helpMessage.substring(0, endOfWhichLocation - 1);
return whichLocation + " " + getVersionInfo(helpMessage);
Pair<String, String> outputs = smokeToolRun(getToolCommand(), getVersionOption());
if(outputs != null) {
if(useErrorOutputForVersion() && outputs.getSecond().length() > 0) {
return getVersionInfo(outputs.getSecond());
}
if(!useErrorOutputForVersion() && outputs.getFirst().length() > 0) {
return getVersionInfo(outputs.getFirst());
}
}
return null;
}
/** Returns the version info contained in the given help message. The default */
/** Flag for using normal or error output for version info. The default uses the normal output. */
protected boolean useErrorOutputForVersion() {
return false;
}
/** Returns the version option. The default is {@code -v}. */
protected String getVersionOption() {
return "-v";
}
/** Returns the version info contained in the given help message. */
protected abstract String getVersionInfo(String helpMessage);
}
......@@ -71,7 +71,7 @@ public class MakeRunner extends GCCToolChainRunnerBase {
/** {@inheritDoc} */
@Override
protected String getVersionInfo(String helpMessage) {
int startOfVersioningInfo = helpMessage.indexOf("GNU Make ");
return helpMessage.substring(startOfVersioningInfo + 9, startOfVersioningInfo + 4);
int startOfVersioningInfo = helpMessage.indexOf("GNU Make ") + 9;
return helpMessage.substring(startOfVersioningInfo, startOfVersioningInfo + 4);
}
}
......@@ -65,13 +65,19 @@ public class ShellRunner extends GCCToolChainRunnerBase {
@Override
public String[] getCommandList() {
// FIXME: -version
return new String[] {"-version"};
return new String[] {getVersionOption()};
}
/** {@inheritDoc} */
@Override
protected String getVersionOption() {
return "-version";
}
/** {@inheritDoc} */
@Override
protected String getVersionInfo(String helpMessage) {
int startOfVersioningInfo = helpMessage.indexOf("version ");
return helpMessage.substring(startOfVersioningInfo + 8, startOfVersioningInfo + 6);
int startOfVersioningInfo = helpMessage.indexOf("version ") + 8;
return helpMessage.substring(startOfVersioningInfo, startOfVersioningInfo + 6);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment