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 { ...@@ -73,4 +73,10 @@ public class GCCRunner extends GCCToolChainRunnerBase {
int startOfVersioningInfo = helpMessage.indexOf("gcc version "); int startOfVersioningInfo = helpMessage.indexOf("gcc version ");
return helpMessage.substring(startOfVersioningInfo + 12, startOfVersioningInfo + 17); 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> ...@@ -45,20 +45,28 @@ public abstract class GCCToolChainRunnerBase extends SimpleToolRunnerBase<File>
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String testToolAvailability() { public String testToolAvailability() {
String toolCmd = "which " + getToolCommand() + " && " + getToolCommand(); Pair<String, String> outputs = smokeToolRun(getToolCommand(), getVersionOption());
Pair<String, String> outputs = smokeToolRun(toolCmd, "-v"); if(outputs != null) {
if(outputs != null && outputs.getSecond().length() > 0) { if(useErrorOutputForVersion() && outputs.getSecond().length() > 0) {
String helpMessage = outputs.getSecond(); return getVersionInfo(outputs.getSecond());
}
String whichOutput = "/" + getToolCommand() + "\n"; if(!useErrorOutputForVersion() && outputs.getFirst().length() > 0) {
int endOfWhichLocation = helpMessage.indexOf(whichOutput) + whichOutput.length(); return getVersionInfo(outputs.getFirst());
String whichLocation = helpMessage.substring(0, endOfWhichLocation - 1); }
return whichLocation + " " + getVersionInfo(helpMessage);
} }
return null; 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); protected abstract String getVersionInfo(String helpMessage);
} }
...@@ -71,7 +71,7 @@ public class MakeRunner extends GCCToolChainRunnerBase { ...@@ -71,7 +71,7 @@ public class MakeRunner extends GCCToolChainRunnerBase {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected String getVersionInfo(String helpMessage) { protected String getVersionInfo(String helpMessage) {
int startOfVersioningInfo = helpMessage.indexOf("GNU Make "); int startOfVersioningInfo = helpMessage.indexOf("GNU Make ") + 9;
return helpMessage.substring(startOfVersioningInfo + 9, startOfVersioningInfo + 4); return helpMessage.substring(startOfVersioningInfo, startOfVersioningInfo + 4);
} }
} }
...@@ -65,13 +65,19 @@ public class ShellRunner extends GCCToolChainRunnerBase { ...@@ -65,13 +65,19 @@ public class ShellRunner extends GCCToolChainRunnerBase {
@Override @Override
public String[] getCommandList() { public String[] getCommandList() {
// FIXME: -version // FIXME: -version
return new String[] {"-version"}; return new String[] {getVersionOption()};
}
/** {@inheritDoc} */
@Override
protected String getVersionOption() {
return "-version";
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected String getVersionInfo(String helpMessage) { protected String getVersionInfo(String helpMessage) {
int startOfVersioningInfo = helpMessage.indexOf("version "); int startOfVersioningInfo = helpMessage.indexOf("version ") + 8;
return helpMessage.substring(startOfVersioningInfo + 8, startOfVersioningInfo + 6); 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