Skip to content

Commit

Permalink
Add more assignment tests in docker (#261)
Browse files Browse the repository at this point in the history
* 4 tests

* Rerun pipeline

---------

Co-authored-by: Martin Mladenov <[email protected]>
  • Loading branch information
alexcojocaru2002 and martinmladenov authored May 1, 2024
1 parent 5a09ef3 commit caecf35
Showing 1 changed file with 45 additions and 45 deletions.
90 changes: 45 additions & 45 deletions .github/scripts/assignments_test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,51 @@ def get_directories(basedir):

pipeline_failed = False
for category_dir in get_directories(home_dir):
#for assignment_dir in get_directories(category_dir):
assignment_dir = random.choice(get_directories(category_dir));
# Remove the contents of the output directory.
os.system(f'rm -r {output_dir}')

# Remove the contents of the test directory.
os.system(f'rm -r {test_dir}/*')

# Write environment file
with open(f'{test_dir}/.env', 'w') as envfile:
envfile.write('TASK_MODE=FULL_WITH_HINTS')

# Copy the assignment to the test folder.
os.chdir(assignment_dir)
os.system(f'cp ./config/Configuration.java {test_dir}/test.txt')
os.system(f'cp ./solution/*.java {test_dir}/solution.txt')
os.system(f'cp ./src/main/java/delft/*.java {test_dir}/library.txt')
# Copy resources
os.system('find . -type f | ' +
'grep -i -v "^\./src/" | grep -i -v "\./config/Configuration.java" | ' +
'grep -i -v "^\./pom.xml$" | grep -i -v "^\./solution/" | grep -i -v "^\./README.md$" | ' +
'xargs -i cp --parents {} ' + f'{test_dir}/')

# Switch to Docker directory
os.chdir(docker_dir)

# Run `andy` on the current assignment.
output = os.popen('make github-ci.test').read()

re_score = re.search('Final grade: [0-9]+', output)
score = int(re_score.group().split()[2]) if re_score else -1
re_andy_version = re.search('Andy v.+', output)
andy_version = re_andy_version.group() if re_andy_version else "Unknown Andy version"

# Print the score for the assignment.
print(f'{andy_version} | {assignment_dir.split("/")[-2]}/{assignment_dir.split("/")[-1]}: {score}/100')

# Update the `pipeline_failed` variable.
if score != 100:
print(output)
pipeline_failed = True

if expected_andy_version not in andy_version:
print(f'Error: Unexpected Andy version {andy_version}, expected {expected_andy_version}')
pipeline_failed = True
for assignment_dir in random.choices(get_directories(category_dir), k=4):
# Remove the contents of the output directory.
os.system(f'rm -r {output_dir}')

# Remove the contents of the test directory.
os.system(f'rm -r {test_dir}/*')

# Write environment file
with open(f'{test_dir}/.env', 'w') as envfile:
envfile.write('TASK_MODE=FULL_WITH_HINTS')

# Copy the assignment to the test folder.
os.chdir(assignment_dir)
os.system(f'cp ./config/Configuration.java {test_dir}/test.txt')
os.system(f'cp ./solution/*.java {test_dir}/solution.txt')
os.system(f'cp ./src/main/java/delft/*.java {test_dir}/library.txt')
# Copy resources
os.system('find . -type f | ' +
'grep -i -v "^\./src/" | grep -i -v "\./config/Configuration.java" | ' +
'grep -i -v "^\./pom.xml$" | grep -i -v "^\./solution/" | grep -i -v "^\./README.md$" | ' +
'xargs -i cp --parents {} ' + f'{test_dir}/')

# Switch to Docker directory
os.chdir(docker_dir)

# Run `andy` on the current assignment.
output = os.popen('make github-ci.test').read()

re_score = re.search('Final grade: [0-9]+', output)
score = int(re_score.group().split()[2]) if re_score else -1
re_andy_version = re.search('Andy v.+', output)
andy_version = re_andy_version.group() if re_andy_version else "Unknown Andy version"

# Print the score for the assignment.
print(f'{andy_version} | {assignment_dir.split("/")[-2]}/{assignment_dir.split("/")[-1]}: {score}/100')

# Update the `pipeline_failed` variable.
if score != 100:
print(output)
pipeline_failed = True

if expected_andy_version not in andy_version:
print(f'Error: Unexpected Andy version {andy_version}, expected {expected_andy_version}')
pipeline_failed = True

if pipeline_failed:
sys.exit('Some assignments do not have 100/100.')

0 comments on commit caecf35

Please sign in to comment.