Skip to content

Commit 5f3b312

Browse files
authored
Merge pull request #14 from UMM-CSci-Systems/add-mergesort-to-arraymerge-compile
Add `mergesort.c` to files to compile in GitHub Actions
2 parents 5b05d14 + b5ce9e2 commit 5f3b312

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

.github/workflows/arraymerge_gtest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Check out the code
3434
uses: actions/checkout@v2
3535
- name: Compile test code
36-
run: g++ -Wall -g -o array_merge_test array_merge.c array_merge_test.cpp -lgtest -pthread -std=c++0x
36+
run: g++ -Wall -g -o array_merge_test ../mergesort/mergesort.c array_merge.c array_merge_test.cpp -lgtest -pthread -std=c++0x
3737
working-directory: array_merge
3838
- name: Run test
3939
run: ./array_merge_test

.github/workflows/arraymerge_test_valgrind.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Check out the code
3636
uses: actions/checkout@v2
3737
- name: Compile code
38-
run: g++ -Wall -g -o array_merge_test array_merge.c array_merge_test.cpp -lgtest -pthread -std=c++0x
38+
run: g++ -Wall -g -o array_merge_test ../mergesort/mergesort.c array_merge.c array_merge_test.cpp -lgtest -pthread -std=c++0x
3939
working-directory: array_merge
4040
- name: Run test
4141
run: valgrind -v --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./array_merge_test

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ test code to handle memory leaks
3838
Do be careful to not remove or weaken the tests, though; at a minimum
3939
you definitely want to be able to pass the tests as given.
4040

41+
:bangbang: Neither of the parts of this lab comes with a `main()` function.
42+
We could add one, but both of the target functions (`mergesort()` and
43+
`array_merge()`) are really "library" functions that don't make a
44+
lot of sense as functions that users would interact with directly. So
45+
we just have them called by the tests but don't provide a way for you
46+
to call them directly. If you want to create a `main.c` for either or
47+
both of the projects feel free to do so, but it's definitely not
48+
expected.
49+
4150
## Fixing memory problems
4251

4352
Passing the tests is arguably just the first half of each of these problems,
@@ -129,6 +138,12 @@ Some things to watch our for:
129138

130139
There are more comprehensive tips and suggestions in `Tips_and_suggestions.md` in the repository.
131140

141+
:bangbang: The Array Merge problem depends on the Mergesort problem, so you really
142+
should do Mergesort first. The GitHub Actions (that run the tests automatically and
143+
create things like the status badges) actually include `mergesort.c` when they
144+
compile the Array Merge code, so if `mergesort.c` is incomplete or otherwise
145+
broken that will cause the Array Merge tests to fail.
146+
132147
### Mergesort
133148

134149
Your task here is to implement a well known sorting algorithm in C,
@@ -222,7 +237,22 @@ the array without messing with that important first element.
222237
You can use references like `../mergesort/mergesort.h` or
223238
`../mergesort/mergesort.c` to access appropriate files in that part of
224239
the project, either in things like `#include` statements or
225-
in `gcc/g++` calls.
240+
in `gcc/g++` calls. The command in the GitHub Actions to compile
241+
the Array Merge tess, for example, is:
242+
243+
```text
244+
g++ -Wall -g -o array_merge_test ../mergesort/mergesort.c array_merge.c array_merge_test.cpp -lgtest -pthread -std=c++0x
245+
```
246+
247+
Note that the `../mergesort/mergesort.c` in this command includes
248+
the Mergesort `.c` file in the list of files that will be compiled
249+
and linked together to form the `array_merge_test` executable.
250+
That has two major implications:
251+
252+
- You *must* have a working `mergesort.c` in order to get the GitHub
253+
Actions for Array Merge to compile successfully.
254+
- You *can* (and presumably should?) use the function `mergesort()` that
255+
you define in the other part of the lab here in Array Merge.
226256

227257
## Final Words
228258

array_merge/array_merge.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "array_merge.h"
2+
#include "../mergesort/mergesort.h"
23

34
int* array_merge(int num_arrays, int* sizes, int** values) {
45
// This is obviously broken. It has the right type, though, eh?

0 commit comments

Comments
 (0)