Création d'un script de test automatique pour le test n°1 + Amélioration du readme.md d'explication
This commit is contained in:
83
tests/C/test-01-from-nothing/run_test01.sh
Executable file
83
tests/C/test-01-from-nothing/run_test01.sh
Executable file
@@ -0,0 +1,83 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script de test pour comparer bake et make dans le test n°1 - Compilation à partir de rien
|
||||
|
||||
# Création du répertoire de logs s'il n'existe pas
|
||||
mkdir -p logs
|
||||
|
||||
# Fichier de log avec timestamp pour éviter les écrasements
|
||||
LOG_FILE="logs/test01_$(date +%Y%m%d_%H%M%S).log"
|
||||
|
||||
echo "=================================" | tee -a "$LOG_FILE"
|
||||
echo "Test 01 - Compilation à partir de rien" | tee -a "$LOG_FILE"
|
||||
echo "=================================" | tee -a "$LOG_FILE"
|
||||
echo "" | tee -a "$LOG_FILE"
|
||||
|
||||
# Nettoyage préalable pour s'assurer qu'on part de zéro
|
||||
echo "Nettoyage préalable..." | tee -a "$LOG_FILE"
|
||||
cd make && make clean &>/dev/null || true
|
||||
cd ../bake && java -cp bakefile.jar fr.monlouyan.bakefile.Main clean &>/dev/null || true
|
||||
cd ..
|
||||
echo "" | tee -a "$LOG_FILE"
|
||||
|
||||
# Test avec make
|
||||
echo "=================================" | tee -a "$LOG_FILE"
|
||||
echo "Exécution de MAKE:" | tee -a "$LOG_FILE"
|
||||
echo "=================================" | tee -a "$LOG_FILE"
|
||||
cd make
|
||||
echo "$ make" | tee -a "../$LOG_FILE"
|
||||
make 2>&1 | tee -a "../$LOG_FILE"
|
||||
MAKE_EXIT_CODE=$?
|
||||
echo "" | tee -a "../$LOG_FILE"
|
||||
echo "Code de sortie: $MAKE_EXIT_CODE" | tee -a "../$LOG_FILE"
|
||||
|
||||
# Vérification de l'exécutable make
|
||||
if [ -f "main" ]; then
|
||||
echo "Exécutable 'main' créé avec succès par make" | tee -a "../$LOG_FILE"
|
||||
echo "$ ./main" | tee -a "../$LOG_FILE"
|
||||
./main 2>&1 | tee -a "../$LOG_FILE"
|
||||
else
|
||||
echo "ERREUR: Exécutable 'main' non créé par make" | tee -a "../$LOG_FILE"
|
||||
fi
|
||||
echo "" | tee -a "../$LOG_FILE"
|
||||
|
||||
cd ..
|
||||
|
||||
# Test avec bake
|
||||
echo "=================================" | tee -a "$LOG_FILE"
|
||||
echo "Exécution de BAKE:" | tee -a "$LOG_FILE"
|
||||
echo "=================================" | tee -a "$LOG_FILE"
|
||||
cd bake
|
||||
echo "$ java -cp bakefile.jar fr.monlouyan.bakefile.Main" | tee -a "../$LOG_FILE"
|
||||
java -cp bakefile.jar fr.monlouyan.bakefile.Main 2>&1 | tee -a "../$LOG_FILE"
|
||||
BAKE_EXIT_CODE=$?
|
||||
echo "" | tee -a "../$LOG_FILE"
|
||||
echo "Code de sortie: $BAKE_EXIT_CODE" | tee -a "../$LOG_FILE"
|
||||
|
||||
# Vérification de l'exécutable bake
|
||||
if [ -f "main" ]; then
|
||||
echo "Exécutable 'main' créé avec succès par bake" | tee -a "../$LOG_FILE"
|
||||
echo "$ ./main" | tee -a "../$LOG_FILE"
|
||||
./main 2>&1 | tee -a "../$LOG_FILE"
|
||||
else
|
||||
echo "ERREUR: Exécutable 'main' non créé par bake" | tee -a "../$LOG_FILE"
|
||||
fi
|
||||
echo "" | tee -a "../$LOG_FILE"
|
||||
|
||||
cd ..
|
||||
|
||||
# Résumé des résultats
|
||||
echo "=================================" | tee -a "$LOG_FILE"
|
||||
echo "RÉSUMÉ:" | tee -a "$LOG_FILE"
|
||||
echo "=================================" | tee -a "$LOG_FILE"
|
||||
|
||||
if [ $MAKE_EXIT_CODE -eq 0 ] && [ $BAKE_EXIT_CODE -eq 0 ]; then
|
||||
echo "✅ Les deux outils ont réussi la compilation" | tee -a "$LOG_FILE"
|
||||
else
|
||||
echo "❌ Au moins un des outils a échoué" | tee -a "$LOG_FILE"
|
||||
echo " - make: $([ $MAKE_EXIT_CODE -eq 0 ] && echo '✅ Succès' || echo '❌ Échec')" | tee -a "$LOG_FILE"
|
||||
echo " - bake: $([ $BAKE_EXIT_CODE -eq 0 ] && echo '✅ Succès' || echo '❌ Échec')" | tee -a "$LOG_FILE"
|
||||
fi
|
||||
|
||||
echo "" | tee -a "$LOG_FILE"
|
||||
echo "Test terminé. Résultats enregistrés dans: $LOG_FILE" | tee -a "$LOG_FILE"
|
Reference in New Issue
Block a user