From 1d04113e347a6323b3615ecf26e3b76b23720a6e Mon Sep 17 00:00:00 2001 From: Plebysnek <115377141+Plebysnacc@users.noreply.github.com> Date: Wed, 16 Apr 2025 14:35:28 +0200 Subject: [PATCH 1/6] rename broken files so tests detect them as such --- Makefile | 10 +++---- files/{fehler3.cpp => noBracket_broken.cpp} | 0 files/{fehler1.cpp => noImport_broken.cpp} | 2 ++ .../{fehler5.cpp => noSemicolon2_broken.cpp} | 0 files/{fehler2.cpp => noSemicolon_broken.cpp} | 0 ...{fehler4.cpp => wrongDirection_broken.cpp} | 0 lektionen/errors_warnings.tex | 29 ++++++++++--------- 7 files changed, 23 insertions(+), 18 deletions(-) rename files/{fehler3.cpp => noBracket_broken.cpp} (100%) rename files/{fehler1.cpp => noImport_broken.cpp} (78%) rename files/{fehler5.cpp => noSemicolon2_broken.cpp} (100%) rename files/{fehler2.cpp => noSemicolon_broken.cpp} (100%) rename files/{fehler4.cpp => wrongDirection_broken.cpp} (100%) diff --git a/Makefile b/Makefile index cfdb077..715dabe 100644 --- a/Makefile +++ b/Makefile @@ -32,11 +32,11 @@ dir: files/* @echo "Dateien kopieren…" @cp files/helloworld.cpp vorkurs/lektion01/. > /dev/null @cp files/helloyou.cpp vorkurs/lektion03/. > /dev/null - @cp files/fehler1.cpp vorkurs/lektion04/. > /dev/null - @cp files/fehler2.cpp vorkurs/lektion04/. > /dev/null - @cp files/fehler3.cpp vorkurs/lektion04/. > /dev/null - @cp files/fehler4.cpp vorkurs/lektion04/. > /dev/null - @cp files/fehler5.cpp vorkurs/lektion04/. > /dev/null + @cp files/noImport_broken.cpp vorkurs/lektion04/. > /dev/null + @cp files/noSemicolon_broken.cpp vorkurs/lektion04/. > /dev/null + @cp files/noBracket_broken.cpp vorkurs/lektion04/. > /dev/null + @cp files/wrongDirection_broken.cpp vorkurs/lektion04/. > /dev/null + @cp files/noSemicolon2_broken.cpp vorkurs/lektion04/. > /dev/null @cp files/variablen.cpp vorkurs/lektion05/. > /dev/null @cp files/arith1.cpp vorkurs/lektion07/. > /dev/null @cp files/arith2.cpp vorkurs/lektion07/. > /dev/null diff --git a/files/fehler3.cpp b/files/noBracket_broken.cpp similarity index 100% rename from files/fehler3.cpp rename to files/noBracket_broken.cpp diff --git a/files/fehler1.cpp b/files/noImport_broken.cpp similarity index 78% rename from files/fehler1.cpp rename to files/noImport_broken.cpp index f4fb8f8..20a0cfa 100644 --- a/files/fehler1.cpp +++ b/files/noImport_broken.cpp @@ -1,3 +1,5 @@ +#include + int main() { std::cout << "Hello world" << std::endl; diff --git a/files/fehler5.cpp b/files/noSemicolon2_broken.cpp similarity index 100% rename from files/fehler5.cpp rename to files/noSemicolon2_broken.cpp diff --git a/files/fehler2.cpp b/files/noSemicolon_broken.cpp similarity index 100% rename from files/fehler2.cpp rename to files/noSemicolon_broken.cpp diff --git a/files/fehler4.cpp b/files/wrongDirection_broken.cpp similarity index 100% rename from files/fehler4.cpp rename to files/wrongDirection_broken.cpp diff --git a/lektionen/errors_warnings.tex b/lektionen/errors_warnings.tex index 2519e8b..c7364e0 100644 --- a/lektionen/errors_warnings.tex +++ b/lektionen/errors_warnings.tex @@ -18,19 +18,22 @@ Nehmen wir z.B. mal folgendes Programm: -\inputcpp{fehler1.cpp} +\inputcpp{noImport_broken.cpp} Wenn wir versuchen, dieses zu kompilieren, gibt uns \texttt{g++} folgendes aus: -\begin{textcode*}{label=g++ -o fehler1 fehler1.cpp} - fehler1.cpp: In function 'int main()': - fehler1.cpp:2:5: error: 'cout' is not a member of 'std' - fehler1.cpp:2:35: error: 'endl' is not a member of 'std' +\begin{textcode*}{label=g++ -o noImport_broken noImport_broken.cpp} + noImport_broken.cpp: In function 'int main()': + noImport_broken.cpp:2:5: error: 'cout' is not a member of 'std' + noImport_broken.cpp:2:35: error: 'endl' is not a member of 'std' \end{textcode*} +Je nach Compiler und Betriebssystem kann die Nachricht abweichen, im generellen ist der Fehler +aber immer auf das \texttt{std} bzw \texttt{cout} und \texttt{endl} zurückzuführen. + Wenn wir diese Fehlermeldung verstehen wollen, fangen wir immer ganz oben an, egal wie viel Text uns der Compiler ausspucken mag. In diesem Fall sagt uns die -erste Zeile, in welcher Datei (\texttt{fehler1.cpp}) der Fehler aufgetreten ist +erste Zeile, in welcher Datei (\texttt{noImport_broken.cpp}) der Fehler aufgetreten ist und in welcher Funktion (\texttt{int main()}). Die beiden Zeilen danach sind sogar noch spezifischer: Sie enthalten zu Beginn den Dateinamen, dann einen Doppelpunkt, gefolgt von einer Zeilennummer, gefolgt von einer @@ -50,14 +53,14 @@ Der nächste sehr häufig vorkommende Fehler ist subtiler: -\inputcpp{fehler2.cpp} +\inputcpp{noSemicolon_broken.cpp} Wenn wir versuchen, dies zu kompilieren, bekommen wir vom Compiler entgegengespuckt: -\begin{textcode*}{label=g++ -o fehler2 fehler2.cpp} - fehler2.cpp: In function 'int main()': - fehler2.cpp:5:1: error: expected ';' before '}' token +\begin{textcode*}{label=g++ -o fehler2 noSemicolon_broken.cpp} + noSemicolon_broken.cpp: In function 'int main()': + noSemicolon_broken.cpp:5:1: error: expected ';' before '}' token \end{textcode*} Wiederum sagt uns die erste Zeile, in welcher Datei und Funktion der Fehler @@ -88,8 +91,8 @@ korrekt arbeitet (schaut euch ggf. die bisher gezeigten Quellcodes an)? \end{enumerate} -\inputcpp{fehler3.cpp} -\inputcpp{fehler4.cpp} +\inputcpp{noBracket_broken.cpp} +\inputcpp{wrongDirection_broken.cpp} \begin{spiel} \begin{enumerate} @@ -103,7 +106,7 @@ \end{enumerate} \end{spiel} -\inputcpp{fehler5.cpp} +\inputcpp{noSemicolon2_broken.cpp} \textbf{Quiz 4}\\ \textit{Was hiervon sind Fehler, die dazu führen, dass eine Datei nicht kompiliert werden kann?} From 476f739ecd79eb9b850f33e80c2c6438872861d0 Mon Sep 17 00:00:00 2001 From: Plebysnek <115377141+Plebysnacc@users.noreply.github.com> Date: Wed, 16 Apr 2025 14:43:30 +0200 Subject: [PATCH 2/6] break file that should be broken and change test conditions --- .github/workflows/test_scripts/check_compilability.py | 11 +++++++---- files/noImport_broken.cpp | 2 -- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test_scripts/check_compilability.py b/.github/workflows/test_scripts/check_compilability.py index 4bec112..239dd7e 100644 --- a/.github/workflows/test_scripts/check_compilability.py +++ b/.github/workflows/test_scripts/check_compilability.py @@ -18,16 +18,19 @@ def find_all_cpp_files(findWorking): def test_single_cpp_file(file_path, shouldCompile): - compile_status = subprocess.getoutput(f"g++ {file_path}") + compile_status = subprocess.getoutput(f"g++ {file_path} -w") - if (compile_status != "" and shouldCompile) or ( - compile_status == "" and not shouldCompile - ): + if compile_status != "" and shouldCompile: print("\n" + 20 * "=") print(f"Error in file {file_path}:\n") print(compile_status) print(20 * "=" + "\n") return False + elif compile_status == "" and not shouldCompile: + print("\n" + 20 * "=") + print(f"File {file_path} compiles, but should be broken") + print("\n" + 20 * "=") + return False return True diff --git a/files/noImport_broken.cpp b/files/noImport_broken.cpp index 20a0cfa..f4fb8f8 100644 --- a/files/noImport_broken.cpp +++ b/files/noImport_broken.cpp @@ -1,5 +1,3 @@ -#include - int main() { std::cout << "Hello world" << std::endl; From e0d1cd7a28a19d44100154edbbe48fb75d39cf28 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 16 Apr 2025 15:02:58 +0200 Subject: [PATCH 3/6] Fix compilability script --- .../workflows/test_scripts/check_compilability.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test_scripts/check_compilability.py b/.github/workflows/test_scripts/check_compilability.py index 239dd7e..a0476eb 100644 --- a/.github/workflows/test_scripts/check_compilability.py +++ b/.github/workflows/test_scripts/check_compilability.py @@ -2,8 +2,7 @@ import subprocess # Thats where our cpps are currently -BASE_PATH = "vorkurs/" - +BASE_PATH = "files/" def find_all_cpp_files(findWorking): vorkurs_path = pathlib.Path(BASE_PATH) @@ -25,16 +24,17 @@ def test_single_cpp_file(file_path, shouldCompile): print(f"Error in file {file_path}:\n") print(compile_status) print(20 * "=" + "\n") + return False elif compile_status == "" and not shouldCompile: print("\n" + 20 * "=") print(f"File {file_path} compiles, but should be broken") print("\n" + 20 * "=") + return False return True - def main(): error_count_working = 0 error_count_broken = 0 @@ -53,12 +53,13 @@ def main(): print( f"::error::Found {error_count_working} non compiling files which should compile" ) - exit(1) - + if error_count_broken > 0: print( - f"::error:Found {error_count_broken} files that should be broken but compile" + f"::error::Found {error_count_broken} files that should be broken but compile" ) + + if error_count_broken > 0 or error_count_working > 0: exit(1) exit(0) From a9501f7c0f67fe43a9f18359bc3347de94c62487 Mon Sep 17 00:00:00 2001 From: Plebysnek <115377141+Plebysnacc@users.noreply.github.com> Date: Wed, 16 Apr 2025 15:15:34 +0200 Subject: [PATCH 4/6] add example file for arrays --- files/array.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/files/array.cpp b/files/array.cpp index e69de29..0437c02 100644 --- a/files/array.cpp +++ b/files/array.cpp @@ -0,0 +1,18 @@ +#include + +int main() { + // Hier initialisieren wir das Array + int numbers[5] = {1, 4, 3, 9, 100}; + + // Wir zählen ab 0, das 5. Element hat also den Index 4 + int letzteZahl = numbers[4]; + + // So könnte man das Array in der Konsole ausgeben + std::cout << "Das Array beinhaltet die Zahlen" << std::endl; + + for (int n = 0; n < 5; n++) { + std::cout << numbers[n] << " "; + } + + return 0; +} From 1efc926fa4a7179ae4de5f00b7b6457c6962b8f8 Mon Sep 17 00:00:00 2001 From: Plebysnek <115377141+Plebysnacc@users.noreply.github.com> Date: Thu, 17 Apr 2025 14:33:41 +0200 Subject: [PATCH 5/6] fix underscores crashing compilation --- Makefile | 2 +- lektionen/errors_warnings.tex | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 715dabe..3e9f9e4 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ dir: files/* @cp files/helloworld.cpp vorkurs/lektion01/. > /dev/null @cp files/helloyou.cpp vorkurs/lektion03/. > /dev/null @cp files/noImport_broken.cpp vorkurs/lektion04/. > /dev/null - @cp files/noSemicolon_broken.cpp vorkurs/lektion04/. > /dev/null + @cp files/noSemicolon2_broken.cpp vorkurs/lektion04/. > /dev/null @cp files/noBracket_broken.cpp vorkurs/lektion04/. > /dev/null @cp files/wrongDirection_broken.cpp vorkurs/lektion04/. > /dev/null @cp files/noSemicolon2_broken.cpp vorkurs/lektion04/. > /dev/null diff --git a/lektionen/errors_warnings.tex b/lektionen/errors_warnings.tex index c7364e0..22a95ff 100644 --- a/lektionen/errors_warnings.tex +++ b/lektionen/errors_warnings.tex @@ -18,14 +18,14 @@ Nehmen wir z.B. mal folgendes Programm: -\inputcpp{noImport_broken.cpp} +\inputcpp{noImport\string_broken.cpp} Wenn wir versuchen, dieses zu kompilieren, gibt uns \texttt{g++} folgendes aus: -\begin{textcode*}{label=g++ -o noImport_broken noImport_broken.cpp} - noImport_broken.cpp: In function 'int main()': - noImport_broken.cpp:2:5: error: 'cout' is not a member of 'std' - noImport_broken.cpp:2:35: error: 'endl' is not a member of 'std' +\begin{textcode*}{label=g++ -o fehler1 noImport\_broken.cpp} + noImport\_broken.cpp: In function 'int main()': + noImport\_broken.cpp:2:5: error: 'cout' is not a member of 'std' + noImport\_broken.cpp:2:35: error: 'endl' is not a member of 'std' \end{textcode*} Je nach Compiler und Betriebssystem kann die Nachricht abweichen, im generellen ist der Fehler @@ -33,7 +33,7 @@ Wenn wir diese Fehlermeldung verstehen wollen, fangen wir immer ganz oben an, egal wie viel Text uns der Compiler ausspucken mag. In diesem Fall sagt uns die -erste Zeile, in welcher Datei (\texttt{noImport_broken.cpp}) der Fehler aufgetreten ist +erste Zeile, in welcher Datei (\texttt{noImport\string_broken.cpp}) der Fehler aufgetreten ist und in welcher Funktion (\texttt{int main()}). Die beiden Zeilen danach sind sogar noch spezifischer: Sie enthalten zu Beginn den Dateinamen, dann einen Doppelpunkt, gefolgt von einer Zeilennummer, gefolgt von einer @@ -53,14 +53,14 @@ Der nächste sehr häufig vorkommende Fehler ist subtiler: -\inputcpp{noSemicolon_broken.cpp} +\inputcpp{noSemicolon\string_broken.cpp} Wenn wir versuchen, dies zu kompilieren, bekommen wir vom Compiler entgegengespuckt: -\begin{textcode*}{label=g++ -o fehler2 noSemicolon_broken.cpp} - noSemicolon_broken.cpp: In function 'int main()': - noSemicolon_broken.cpp:5:1: error: expected ';' before '}' token +\begin{textcode*}{label=g++ -o fehler2 noSemicolon\_broken.cpp} + noSemicolon\_broken.cpp: In function 'int main()': + noSemicolon\_broken.cpp:5:1: error: expected ';' before '\}' token \end{textcode*} Wiederum sagt uns die erste Zeile, in welcher Datei und Funktion der Fehler @@ -91,8 +91,8 @@ korrekt arbeitet (schaut euch ggf. die bisher gezeigten Quellcodes an)? \end{enumerate} -\inputcpp{noBracket_broken.cpp} -\inputcpp{wrongDirection_broken.cpp} +\inputcpp{noBracket\string_broken.cpp} +\inputcpp{wrongDirection\string_broken.cpp} \begin{spiel} \begin{enumerate} @@ -106,7 +106,7 @@ \end{enumerate} \end{spiel} -\inputcpp{noSemicolon2_broken.cpp} +\inputcpp{noSemicolon2\string_broken.cpp} \textbf{Quiz 4}\\ \textit{Was hiervon sind Fehler, die dazu führen, dass eine Datei nicht kompiliert werden kann?} From f0e3b51eca38cbd072163e7517e723fbf7052fb4 Mon Sep 17 00:00:00 2001 From: fschledorn Date: Fri, 18 Apr 2025 12:12:27 +0200 Subject: [PATCH 6/6] removed obsolete file --- .github/workflow/build_and_test.yml | 80 ----------------------------- 1 file changed, 80 deletions(-) delete mode 100644 .github/workflow/build_and_test.yml diff --git a/.github/workflow/build_and_test.yml b/.github/workflow/build_and_test.yml deleted file mode 100644 index 18812f0..0000000 --- a/.github/workflow/build_and_test.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Build and Run Tests - -on: - push: {} - workflow_dispatch: {} - -jobs: - build: - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: Checkout - uses: actions/checkout@v4 - - uses: xu-cheng/texlive-action@v2 - with: - scheme: full # Consider changing to 'basic' or 'medium' if possible - run: | - apk add make - apk add g++ - apk add zip - make script zip - - uses: actions/upload-artifact@v4 - with: - name: PDF_Test - path: vorkurs.pdf - - check-links: - runs-on: ubuntu-latest - needs: build - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Download compiled PDF - uses: actions/download-artifact@v4 - with: - name: PDF_Test - path: . - - - name: Install pdfgrep - run: sudo apt-get update && sudo apt-get install -y pdfgrep - - - name: Extract and Check URLs - run: | - urls=$(pdfgrep -o -P 'https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)' vorkurs.pdf | sort -u) - error_count=0 - - for url in $urls; do - echo "Checking URL: $url" - - if [[ ! "$url" =~ ^https:// ]]; then - echo "ERROR: URL is not HTTPS: $url" - error_count=$((error_count + 1)) - continue - fi - - if ! curl -Isf --fail-early --connect-timeout 10 "$url" > /dev/null 2>&1; then - curl_error=$(curl -Isf --fail-early --connect-timeout 10 "$url" 2>&1 > /dev/null) - if [[ $curl_error == *"Failed to connect"* ]]; then - echo "ERROR: Connection failed: $url" - elif [[ $curl_error == *"Could not resolve host"* ]]; then - echo "ERROR: DNS resolution failed: $url" - elif [[ $curl_error == *"SSL certificate problem"* ]]; then - echo "ERROR: Initial SSL certificate problem: $url" - else - echo "ERROR: Failed to access: $url (curl error: $curl_error)" - fi - if ! openssl s_client -connect "$(echo "$url" | sed 's/https\?:\/\///' | cut -d/ -f1):443" -servername "$(echo "$url" | sed 's/https\?:\/\///' | cut -d/ -f1)" 2>/dev/null CERTIFICATE ERROR DETECTED!" - fi - - error_count=$((error_count + 1)) - fi - done - - if [ "$error_count" -gt 0 ]; then - echo "::error::Found $error_count broken or insecure links!" - exit 1 - fi - shell: bash