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:
parent
48a376006e
commit
56789b9892
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
9
tests/tests-autres-groupes/amir/bake/Bakefile
Normal file
9
tests/tests-autres-groupes/amir/bake/Bakefile
Normal file
@ -0,0 +1,9 @@
|
||||
all: main
|
||||
|
||||
main:
|
||||
echo "Compilation de main..."
|
||||
touch main
|
||||
|
||||
clean:
|
||||
- rm main
|
||||
@echo "Fichiers nettoyés."
|
0
tests/tests-autres-groupes/amir/bake/main
Normal file
0
tests/tests-autres-groupes/amir/bake/main
Normal file
9
tests/tests-autres-groupes/amir/make/Makefile
Normal file
9
tests/tests-autres-groupes/amir/make/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
all: main
|
||||
|
||||
main:
|
||||
echo "Compilation de main..."
|
||||
touch main
|
||||
|
||||
clean:
|
||||
- rm main
|
||||
@echo "Fichiers nettoyés."
|
0
tests/tests-autres-groupes/amir/make/main
Normal file
0
tests/tests-autres-groupes/amir/make/main
Normal file
Loading…
x
Reference in New Issue
Block a user