Skip to content

Commit d744803

Browse files
committed
ajout pour les test (modif python)
1 parent 7546818 commit d744803

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

ifcc-wat-test.py

+36-5
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,22 @@ def dumpfile(name):
8484

8585
orig_cwd=os.getcwd()
8686
if args.output_dir:
87-
output_dir = os.path.realpath(args.output_dir)
87+
# Si l'utilisateur a spécifié un dossier de sortie, on l'utilise mais en s'assurant qu'il est dans 4IF_PLD
88+
user_output_dir = os.path.realpath(args.output_dir)
89+
base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
90+
pld_path = f"{base_path}/4IF_PLD"
91+
92+
# Vérifier si le chemin spécifié est déjà dans 4IF_PLD
93+
if pld_path in user_output_dir:
94+
output_dir = user_output_dir
95+
else:
96+
# Sinon, utiliser le nom du dossier spécifié mais dans 4IF_PLD
97+
output_dir = os.path.join(pld_path, os.path.basename(user_output_dir))
98+
print(f"Redirection du dossier de sortie vers 4IF_PLD: {output_dir}")
8899
else:
89-
output_dir = os.path.dirname(orig_cwd) + "/ifcc-wat-test-output"
100+
# Si aucun dossier n'est spécifié, créer le dossier par défaut dans 4IF_PLD
101+
base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
102+
output_dir = f"{base_path}/4IF_PLD/ifcc-wat-test-output"
90103

91104
if "ifcc-wat-test-output" in orig_cwd:
92105
print('error: cannot run from within the output directory')
@@ -98,8 +111,18 @@ def dumpfile(name):
98111
os.makedirs(output_dir, exist_ok=True)
99112

100113
# Compilation du projet
101-
print(f"Compilation du projet : {os.path.dirname(orig_cwd)}/compiler")
102-
make_command = f"cd {os.path.dirname(orig_cwd)}/compiler && make -j"
114+
base_path = os.path.dirname(orig_cwd)
115+
compiler_path = f"{base_path}/compiler"
116+
compiler_path_alt = f"{base_path}/4IF_PLD/compiler"
117+
118+
# Vérifie si le chemin standard existe, sinon utilise le chemin alternatif
119+
if not os.path.exists(compiler_path):
120+
compiler_path = compiler_path_alt
121+
print(f"Chemin standard non trouvé, utilisation du chemin alternatif: {compiler_path}")
122+
else:
123+
print(f"Compilation du projet : {compiler_path}")
124+
125+
make_command = f"cd {compiler_path} && make -j"
103126
print(f"Exécution de : {make_command}")
104127
makestatus = command(make_command, "make-compile.txt")
105128
if makestatus != 0:
@@ -149,7 +172,15 @@ def dumpfile(name):
149172
if args.compiler:
150173
compiler = os.path.realpath(os.getcwd() + "/" + args.compiler)
151174
else:
152-
compiler = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + "/4IF_PLD/compiler/ifcc"
175+
base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
176+
ifcc_path = base_path + "/compiler/ifcc"
177+
ifcc_path_alt = base_path + "/4IF_PLD/compiler/ifcc"
178+
179+
# Vérifie si le chemin standard existe, sinon utilise le chemin alternatif
180+
if os.path.isfile(ifcc_path):
181+
compiler = ifcc_path
182+
else:
183+
compiler = ifcc_path_alt
153184

154185
if not os.path.isfile(compiler):
155186
print("error: cannot find ifcc compiler at: " + compiler)

tests/testfiles/13_ControlStructures/13_01_if_else.c

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ int main() {
22
int x = 5;
33
if (x < 7) {
44
x = 8;
5+
} else {
6+
x = 9;
57
}
68
return x;
79
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
int main() {
2+
int x = 7;
3+
if (x < 7) {
4+
x = 8;
5+
} else {
6+
x = 9;
7+
}
8+
return x;
9+
}

0 commit comments

Comments
 (0)