diff --git a/Makefile b/Makefile index de62feb..de0ee03 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/import_assignment b/import_assignment new file mode 100755 index 0000000..56dc94d --- /dev/null +++ b/import_assignment @@ -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 .. \ No newline at end of file diff --git a/test_assignment b/test_assignment new file mode 100755 index 0000000..e66edc4 --- /dev/null +++ b/test_assignment @@ -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 + + +# 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 diff --git a/test_on_public_repo b/test_on_public_repo index b9e1eab..7c10b70 100755 --- a/test_on_public_repo +++ b/test_on_public_repo @@ -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