Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing facilities upgrade #11

Merged
merged 7 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ EXAMPLES := $(addprefix examples_build/,$(notdir $(basename $(wildcard examples/
FILES_ALLOWED_FOR_CHANGE := $(shell cat files_allowed_for_change)
CHANGED_FILES := $(wildcard $(FILES_ALLOWED_FOR_CHANGE))
TEMPLATE_HASH := $(shell cat template_hash)
CFLAGS := --std=gnu11 -Wall -DDEBUG -lpthread
CFLAGS := --std=gnu11 -Wall -DDEBUG -pthread
TESTS := $(wildcard tests/*.self)

CHANNEL_SRC := channel.c channel.h
Expand All @@ -22,7 +22,7 @@ examples_build/%: examples/%.c $(MIMPI_SRC)
gcc $(CFLAGS) -o $@ $(filter %.c,$^)

assignment.zip: $(CHANGED_FILES)
zip assignment.zip $(CHANGED_FILES)
zip assignment.zip $(CHANGED_FILES) template_hash

clean:
rm -rf mimpirun assignment.zip examples_build
14 changes: 14 additions & 0 deletions import_assignment
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

# extract solution
unzip "$1" -d assignment

# populate public_repo with files from assignment.zip which are allowed for change
cd assignment
for file in `cat ../files_allowed_for_change`
do
cp "$file" "../$file"
done
cd ..
27 changes: 27 additions & 0 deletions test_assignment
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -e

if [ $# -ne 2 -o "$2" != "--force" ]
then
echo "Usage: ./test_assignment PATH_TO_EXPORTED_SOLUTION --force"
echo
echo "THIS SCRIPT WILL REMOVE ALL DATA FROM REPOSITORY - use with care!"
echo
echo "Zip file with solution has to be located outside of repository folder."
echo "This script assumes it is invoked from folder containing repository."
exit 1
fi

Comment on lines +5 to +15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this change. Robustness is key to success!


# remove untracked files from repository
git clean -fd

# reset repository to known state (specified by template hash)
git reset --hard HEAD
git switch --detach `unzip -p "$1" template_hash || echo "origin/main"` || git switch --detach origin/main

./import_assignment "$1"

# build solution and run tests
./test
27 changes: 5 additions & 22 deletions test_on_public_repo
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,13 @@ set -e
make assignment.zip

# check if public repo is available
if [ ! -e "public_repo" ] ; then
if cd public_repo ; then
git restore --source=4fdde04756348850bae8f38647dd81a1eba792bf test_assignment
./test_assignment ../assignment.zip --force
cd ..
else
echo "Reference public repository seems to be missing!"
echo "Automatically fetch it using './update_public_repo'"
echo "or manually place it under 'public_repo/' folder."
exit 1
fi

# reset public_repo folder to known state (specified by template hash)
cd public_repo
git clean -fd
git reset --hard `cat ../template_hash`

# extract solution
unzip ../assignment.zip -d assignment

# populate public_repo with files from assignment.zip which are allowd for change
cd assignment
for file in `cat ../files_allowed_for_change`
do
cp "$file" "../$file"
done
cd ..

# build solution and run tests
./test
cd ..
# rm -rf public_repo