Ajout de la gestion des erreurs ignorées dans CommandExecutor et création de nouveaux fichiers de test pour le Makefile

This commit is contained in:
Louay DARDOURI 2025-03-12 22:03:57 +01:00
parent 48a376006e
commit 56789b9892
5 changed files with 40 additions and 5 deletions
src/fr/monlouyan/bakefile
tests/tests-autres-groupes/amir

@ -76,6 +76,12 @@ public class CommandExecutor {
// Enlever le @ si présent pour exécuter la commande correctement
String actualCommand = silent ? command.substring(1) : command;
boolean ignoreErrors = actualCommand.startsWith("-");
if(ignoreErrors){
actualCommand = actualCommand.substring(1).trim();
}
if (isCircular){
if (!silent) {
System.out.println(actualCommand);
@ -96,14 +102,25 @@ public class CommandExecutor {
// Attendre la fin du processus
int exitCode = process.waitFor();
if (exitCode != 0) {
System.err.println("bake: *** [" + rule.getName() + "] Error " + exitCode);
System.exit(2);
if (exitCode != 0) {
if (ignoreErrors) {
System.err.println("bake: [" + rule.getName() + "] Error " + exitCode + " (ignored)");
} else {
System.err.println("bake: *** [" + rule.getName() + "] Error " + exitCode);
System.exit(2);
}
} else if (exitCode != 0 && ignoreErrors && debug) {
System.out.println("Debug: Command failed with exit code " + exitCode + ", but errors are ignored");
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
System.exit(2);
if(!ignoreErrors){
e.printStackTrace();
System.exit(2);
} else if(debug){
System.out.println("Debug: Command execution failed, but errors are ignored");
e.printStackTrace();
}
}
}
}

@ -0,0 +1,9 @@
all: main
main:
echo "Compilation de main..."
touch main
clean:
- rm main
@echo "Fichiers nettoyés."

@ -0,0 +1,9 @@
all: main
main:
echo "Compilation de main..."
touch main
clean:
- rm main
@echo "Fichiers nettoyés."