From 7feae7edc879f3efcd7553f13ef4789041751d1e Mon Sep 17 00:00:00 2001 From: Nic McPhee Date: Fri, 23 Sep 2022 14:12:21 -0500 Subject: [PATCH 1/4] Add `mergesort.c` to files to compile in GitHub Actions This explicitly adds `mergesort.c` to the compile statement for `array_merge` in the GitHub Actions. Now I need to explain this in the README and make sure they understand what's going on there. --- .github/workflows/arraymerge_gtest.yml | 2 +- .github/workflows/arraymerge_test_valgrind.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/arraymerge_gtest.yml b/.github/workflows/arraymerge_gtest.yml index 8db4324..355d1b0 100644 --- a/.github/workflows/arraymerge_gtest.yml +++ b/.github/workflows/arraymerge_gtest.yml @@ -33,7 +33,7 @@ jobs: - name: Check out the code uses: actions/checkout@v2 - name: Compile test code - run: g++ -Wall -g -o array_merge_test array_merge.c array_merge_test.cpp -lgtest -pthread -std=c++0x + run: g++ -Wall -g -o array_merge_test ../mergesort/mergesort.c array_merge.c array_merge_test.cpp -lgtest -pthread -std=c++0x working-directory: array_merge - name: Run test run: ./array_merge_test diff --git a/.github/workflows/arraymerge_test_valgrind.yml b/.github/workflows/arraymerge_test_valgrind.yml index 40054d8..6e69028 100644 --- a/.github/workflows/arraymerge_test_valgrind.yml +++ b/.github/workflows/arraymerge_test_valgrind.yml @@ -35,7 +35,7 @@ jobs: - name: Check out the code uses: actions/checkout@v2 - name: Compile code - run: g++ -Wall -g -o array_merge_test array_merge.c array_merge_test.cpp -lgtest -pthread -std=c++0x + run: g++ -Wall -g -o array_merge_test ../mergesort/mergesort.c array_merge.c array_merge_test.cpp -lgtest -pthread -std=c++0x working-directory: array_merge - name: Run test run: valgrind -v --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./array_merge_test From 49f1c8c938c6f4c02d99c373b8a36af7e66e26e3 Mon Sep 17 00:00:00 2001 From: Nic McPhee Date: Fri, 23 Sep 2022 14:24:33 -0500 Subject: [PATCH 2/4] Add mergesort to the includes in array merge This will make `mergesort()` available in their array merge code. --- array_merge/array_merge.c | 1 + 1 file changed, 1 insertion(+) diff --git a/array_merge/array_merge.c b/array_merge/array_merge.c index ba053e8..507d2af 100644 --- a/array_merge/array_merge.c +++ b/array_merge/array_merge.c @@ -1,4 +1,5 @@ #include "array_merge.h" +#include "../mergesort/mergesort.h" int* array_merge(int num_arrays, int* sizes, int** values) { // This is obviously broken. It has the right type, though, eh? From 6b6b7a4e9b51b651259a4f9a8703a1f4743b5e50 Mon Sep 17 00:00:00 2001 From: Nic McPhee Date: Fri, 23 Sep 2022 14:26:47 -0500 Subject: [PATCH 3/4] Clarify dependency of Array Merge on Mergesort This adds some text in the README that attempts to clarify the dependency of the Array Merge part of the lab on Mergesort. --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d9033b7..cadcdcc 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,12 @@ Some things to watch our for: There are more comprehensive tips and suggestions in `Tips_and_suggestions.md` in the repository. +:bangbang: The Array Merge problem depends on the Mergesort problem, so you really +should do Mergesort first. The GitHub Actions (that run the tests automatically and +create things like the status badges) actually include `mergesort.c` when they +compile the Array Merge code, so if `mergesort.c` is incomplete or otherwise +broken that will cause the Array Merge tests to fail. + ### Mergesort Your task here is to implement a well known sorting algorithm in C, @@ -222,7 +228,22 @@ the array without messing with that important first element. You can use references like `../mergesort/mergesort.h` or `../mergesort/mergesort.c` to access appropriate files in that part of the project, either in things like `#include` statements or -in `gcc/g++` calls. +in `gcc/g++` calls. The command in the GitHub Actions to compile +the Array Merge tess, for example, is: + +```text +g++ -Wall -g -o array_merge_test ../mergesort/mergesort.c array_merge.c array_merge_test.cpp -lgtest -pthread -std=c++0x +``` + +Note that the `../mergesort/mergesort.c` in this command includes +the Mergesort `.c` file in the list of files that will be compiled +and linked together to form the `array_merge_test` executable. +That has two major implications: + +- You *must* have a working `mergesort.c` in order to get the GitHub + Actions for Array Merge to compile successfully. +- You *can* (and presumably should?) use the function `mergesort()` that + you define in the other part of the lab here in Array Merge. ## Final Words From b5ce9e2c37ad4f04ae5fa392b981ed45383cddb6 Mon Sep 17 00:00:00 2001 From: Nic McPhee Date: Fri, 23 Sep 2022 14:35:11 -0500 Subject: [PATCH 4/4] Add note about the lack of `main()` methods --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index cadcdcc..e3ad9c2 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,15 @@ test code to handle memory leaks Do be careful to not remove or weaken the tests, though; at a minimum you definitely want to be able to pass the tests as given. +:bangbang: Neither of the parts of this lab comes with a `main()` function. +We could add one, but both of the target functions (`mergesort()` and +`array_merge()`) are really "library" functions that don't make a +lot of sense as functions that users would interact with directly. So +we just have them called by the tests but don't provide a way for you +to call them directly. If you want to create a `main.c` for either or +both of the projects feel free to do so, but it's definitely not +expected. + ## Fixing memory problems Passing the tests is arguably just the first half of each of these problems,