Skip to content

Commit afc01c2

Browse files
Tim-GrubeMapManagementfschledorn
authored
Hotfix compile tests try1 (#168)
* rename broken files so tests detect them as such * break file that should be broken and change test conditions * Fix compilability script * add example file for arrays * fix underscores crashing compilation * removed obsolete file --------- Co-authored-by: Jan <MapManagement@protonmail.com> Co-authored-by: fschledorn <nicolas.schledorn@stud.uni-heidelberg.de>
1 parent 6134e5b commit afc01c2

10 files changed

Lines changed: 53 additions & 108 deletions

File tree

.github/workflow/build_and_test.yml

Lines changed: 0 additions & 80 deletions
This file was deleted.

.github/workflows/test_scripts/check_compilability.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import subprocess
33

44
# Thats where our cpps are currently
5-
BASE_PATH = "vorkurs/"
6-
5+
BASE_PATH = "files/"
76

87
def find_all_cpp_files(findWorking):
98
vorkurs_path = pathlib.Path(BASE_PATH)
@@ -18,19 +17,23 @@ def find_all_cpp_files(findWorking):
1817

1918

2019
def test_single_cpp_file(file_path, shouldCompile):
21-
compile_status = subprocess.getoutput(f"g++ {file_path}")
20+
compile_status = subprocess.getoutput(f"g++ {file_path} -w")
2221

23-
if (compile_status != "" and shouldCompile) or (
24-
compile_status == "" and not shouldCompile
25-
):
22+
if compile_status != "" and shouldCompile:
2623
print("\n" + 20 * "=")
2724
print(f"Error in file {file_path}:\n")
2825
print(compile_status)
2926
print(20 * "=" + "\n")
27+
3028
return False
29+
elif compile_status == "" and not shouldCompile:
30+
print("\n" + 20 * "=")
31+
print(f"File {file_path} compiles, but should be broken")
32+
print("\n" + 20 * "=")
3133

32-
return True
34+
return False
3335

36+
return True
3437

3538
def main():
3639
error_count_working = 0
@@ -50,12 +53,13 @@ def main():
5053
print(
5154
f"::error::Found {error_count_working} non compiling files which should compile"
5255
)
53-
exit(1)
54-
56+
5557
if error_count_broken > 0:
5658
print(
57-
f"::error:Found {error_count_broken} files that should be broken but compile"
59+
f"::error::Found {error_count_broken} files that should be broken but compile"
5860
)
61+
62+
if error_count_broken > 0 or error_count_working > 0:
5963
exit(1)
6064

6165
exit(0)

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ dir: files/*
3232
@echo "Dateien kopieren…"
3333
@cp files/helloworld.cpp vorkurs/lektion01/. > /dev/null
3434
@cp files/helloyou.cpp vorkurs/lektion03/. > /dev/null
35-
@cp files/fehler1.cpp vorkurs/lektion04/. > /dev/null
36-
@cp files/fehler2.cpp vorkurs/lektion04/. > /dev/null
37-
@cp files/fehler3.cpp vorkurs/lektion04/. > /dev/null
38-
@cp files/fehler4.cpp vorkurs/lektion04/. > /dev/null
39-
@cp files/fehler5.cpp vorkurs/lektion04/. > /dev/null
35+
@cp files/noImport_broken.cpp vorkurs/lektion04/. > /dev/null
36+
@cp files/noSemicolon2_broken.cpp vorkurs/lektion04/. > /dev/null
37+
@cp files/noBracket_broken.cpp vorkurs/lektion04/. > /dev/null
38+
@cp files/wrongDirection_broken.cpp vorkurs/lektion04/. > /dev/null
39+
@cp files/noSemicolon2_broken.cpp vorkurs/lektion04/. > /dev/null
4040
@cp files/variablen.cpp vorkurs/lektion05/. > /dev/null
4141
@cp files/arith1.cpp vorkurs/lektion07/. > /dev/null
4242
@cp files/arith2.cpp vorkurs/lektion07/. > /dev/null

files/array.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <iostream>
2+
3+
int main() {
4+
// Hier initialisieren wir das Array
5+
int numbers[5] = {1, 4, 3, 9, 100};
6+
7+
// Wir zählen ab 0, das 5. Element hat also den Index 4
8+
int letzteZahl = numbers[4];
9+
10+
// So könnte man das Array in der Konsole ausgeben
11+
std::cout << "Das Array beinhaltet die Zahlen" << std::endl;
12+
13+
for (int n = 0; n < 5; n++) {
14+
std::cout << numbers[n] << " ";
15+
}
16+
17+
return 0;
18+
}

lektionen/errors_warnings.tex

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,22 @@
1818

1919
Nehmen wir z.B. mal folgendes Programm:
2020

21-
\inputcpp{fehler1.cpp}
21+
\inputcpp{noImport\string_broken.cpp}
2222

2323
Wenn wir versuchen, dieses zu kompilieren, gibt uns \texttt{g++} folgendes aus:
2424

25-
\begin{textcode*}{label=g++ -o fehler1 fehler1.cpp}
26-
fehler1.cpp: In function 'int main()':
27-
fehler1.cpp:2:5: error: 'cout' is not a member of 'std'
28-
fehler1.cpp:2:35: error: 'endl' is not a member of 'std'
25+
\begin{textcode*}{label=g++ -o fehler1 noImport\_broken.cpp}
26+
noImport\_broken.cpp: In function 'int main()':
27+
noImport\_broken.cpp:2:5: error: 'cout' is not a member of 'std'
28+
noImport\_broken.cpp:2:35: error: 'endl' is not a member of 'std'
2929
\end{textcode*}
3030

31+
Je nach Compiler und Betriebssystem kann die Nachricht abweichen, im generellen ist der Fehler
32+
aber immer auf das \texttt{std} bzw \texttt{cout} und \texttt{endl} zurückzuführen.
33+
3134
Wenn wir diese Fehlermeldung verstehen wollen, fangen wir immer ganz oben an,
3235
egal wie viel Text uns der Compiler ausspucken mag. In diesem Fall sagt uns die
33-
erste Zeile, in welcher Datei (\texttt{fehler1.cpp}) der Fehler aufgetreten ist
36+
erste Zeile, in welcher Datei (\texttt{noImport\string_broken.cpp}) der Fehler aufgetreten ist
3437
und in welcher Funktion (\texttt{int main()}). Die beiden Zeilen
3538
danach sind sogar noch spezifischer: Sie enthalten zu Beginn den Dateinamen,
3639
dann einen Doppelpunkt, gefolgt von einer Zeilennummer, gefolgt von einer
@@ -50,14 +53,14 @@
5053

5154
Der nächste sehr häufig vorkommende Fehler ist subtiler:
5255

53-
\inputcpp{fehler2.cpp}
56+
\inputcpp{noSemicolon\string_broken.cpp}
5457

5558
Wenn wir versuchen, dies zu kompilieren, bekommen wir vom Compiler
5659
entgegengespuckt:
5760

58-
\begin{textcode*}{label=g++ -o fehler2 fehler2.cpp}
59-
fehler2.cpp: In function 'int main()':
60-
fehler2.cpp:5:1: error: expected ';' before '}' token
61+
\begin{textcode*}{label=g++ -o fehler2 noSemicolon\_broken.cpp}
62+
noSemicolon\_broken.cpp: In function 'int main()':
63+
noSemicolon\_broken.cpp:5:1: error: expected ';' before '\}' token
6164
\end{textcode*}
6265

6366
Wiederum sagt uns die erste Zeile, in welcher Datei und Funktion der Fehler
@@ -88,8 +91,8 @@
8891
korrekt arbeitet (schaut euch ggf. die bisher gezeigten Quellcodes an)?
8992
\end{enumerate}
9093

91-
\inputcpp{fehler3.cpp}
92-
\inputcpp{fehler4.cpp}
94+
\inputcpp{noBracket\string_broken.cpp}
95+
\inputcpp{wrongDirection\string_broken.cpp}
9396

9497
\begin{spiel}
9598
\begin{enumerate}
@@ -103,7 +106,7 @@
103106
\end{enumerate}
104107
\end{spiel}
105108

106-
\inputcpp{fehler5.cpp}
109+
\inputcpp{noSemicolon2\string_broken.cpp}
107110

108111
\textbf{Quiz 4}\\
109112
\textit{Was hiervon sind Fehler, die dazu führen, dass eine Datei nicht kompiliert werden kann?}

0 commit comments

Comments
 (0)