Skip to content

Commit

Permalink
Merge pull request #11 from baktrius/testing-facilities-upgrade
Browse files Browse the repository at this point in the history
Testing facilities upgrade
  • Loading branch information
baktrius authored Dec 29, 2023
2 parents ca8f0e6 + e3a1d6a commit 65bf02a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 24 deletions.
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


# 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

0 comments on commit 65bf02a

Please sign in to comment.