[ClavaWeaver] Changes how unit testing mode is called
@@ -53,6 +53,8 @@ import pt.up.fe.specs.clava.weaver.options.CxxWeaverOptions;
import pt.up.fe.specs.clava.weaver.pragmas.ClavaPragmas;
import pt.up.fe.specs.lang.SpecsPlatforms;
import pt.up.fe.specs.lara.LaraExtraApis;
+import pt.up.fe.specs.lara.unit.LaraUnitLauncher;
+import pt.up.fe.specs.lara.unit.LaraUnitOptions;
import pt.up.fe.specs.util.SpecsCheck;
import pt.up.fe.specs.util.SpecsIo;
import pt.up.fe.specs.util.SpecsLogs;
@@ -1034,7 +1036,32 @@ public class CxxWeaver extends ACxxWeaver {
// }
@Override
- public boolean executeUnitTestMode(List<String> unitTestArgs) {
+ public boolean executeUnitTestMode(DataStore dataStore) {
+
+ DataStore laraUnitData = DataStore.newInstance("LaraUnitData");
+
+ laraUnitData.add(LaraUnitOptions.WEAVER_CLASS, getClass().getName());
+
+ File testFile = dataStore.get(LaraiKeys.LARA_FILE);
+
+ laraUnitData.add(LaraUnitOptions.TEST_FOLDER, testFile);
+
+ List<File> includes = dataStore.get(LaraiKeys.INCLUDES_FOLDER).getFiles();
+ if (includes.isEmpty()) {
+ SpecsLogs.msgInfo("Expected one include, the base folder of the tests");
+ return false;
+ }
+ laraUnitData.add(LaraUnitOptions.BASE_FOLDER, includes.get(0));
+
+ SpecsLogs.debug("Launching lara-unit with the following options: " + laraUnitData);
+
+ int unitResults = LaraUnitLauncher.execute(laraUnitData);
+ return unitResults == 0;
+ // int unitResults = LaraUnitLauncher.execute(laraUnitArgs.toArray(new String[0]));
+
+ // return Optional.of(unitResults != -1);
+
+ /*
// Add flag "-ut" to unit test args
String[] args = new String[unitTestArgs.size() + 1];
args[0] = "-" + LaraiKeys.getUnitTestFlag();
@@ -1046,6 +1073,7 @@ public class CxxWeaver extends ACxxWeaver {
// System.out.println("ARGS:" + Arrays.asList(args));
return ClavaWeaverLauncher.execute(args);
+ */
// if (!unitTestArgs.get(0).equals("-" + LaraiKeys.getUnitTestFlag())) {
// unitTestArgs = new ArrayList<>(unitTestArgs);
