Ajout du test n°14 pour vérifier la suppression d'un fichier source et la recompilation avec Bake et Make

This commit is contained in:
Moncef STITI 2025-02-09 17:59:59 +01:00
parent 547086887d
commit b2ebd69808
5 changed files with 85 additions and 0 deletions
tests/C/test-14-remove-source-and-rebuild

@ -0,0 +1,63 @@
# Test n°14 - Suppression d'un fichier source et recompilation
## Objectif
Ce test a pour but de vérifier comment **Bake** et **Make** réagissent lorsque le fichier source `.c` est supprimé après la première compilation et qu'une recompilation est demandée.
## Structure du projet
Le test est organisé en deux répertoires :
```
.
├── bake
│ ├── Bakefile # Fichier de build pour Bake
│ ├── bakefile.jar # Fichier Bake pré-compilé
│ └── test.c # Fichier source C
├── bakefile.jar # Copie du fichier Bake
└── make
├── Makefile # Fichier de build pour Make
└── test.c # Fichier source C
```
## Étapes du test
### 1. Compilation initiale
#### **Avec Bake**
Exécutez les commandes suivantes :
```sh
cd bake
java -cp bakefile.jar fr.monlouyan.bakefile.Main
```
Vous devriez voir la compilation de `test.c` en `test.o`.
#### **Avec Make**
Exécutez les commandes suivantes :
```sh
cd ../make
make
```
Cela devrait également compiler `test.c` en `test.o`.
### 2. Suppression du fichier source
Dans chaque répertoire (`bake/` et `make/`), supprimez `test.c` :
```sh
rm test.c
```
### 3. Recompilation
#### **Avec Bake**
```sh
java -cp bakefile.jar fr.monlouyan.bakefile.Main
```
#### **Avec Make**
```sh
make
```
## Résultats attendus
Si `Bake` fonctionne comme `Make`, nous devrions observer une erreur de compilation, car `test.c` est manquant.
Exemple de sortie attendue :
```
make: *** No rule to make target `test.c', needed by `test.o'. Stop.
```

@ -0,0 +1,5 @@
CC = gcc
CFLAGS = -Wall -Wextra -c
test.o: test.c
$(CC) $(CFLAGS) -o test.o test.c

@ -0,0 +1,6 @@
#include <stdio.h>
int main(void) {
printf("Hello, Bake!\n");
return 0;
}

@ -0,0 +1,5 @@
CC = gcc
CFLAGS = -Wall -Wextra -c
test.o: test.c
$(CC) $(CFLAGS) -o test.o test.c

@ -0,0 +1,6 @@
#include <stdio.h>
int main(void) {
printf("Hello, Bake!\n");
return 0;
}