Skip to content

Commit

Permalink
Merge pull request #266 from pehrsoderman/include-example-in-manifest
Browse files Browse the repository at this point in the history
Fix running of tests using pybuild
  • Loading branch information
pehrsoderman authored Jun 18, 2024
2 parents 0d8c2f8 + b6dedd1 commit ab2e34e
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 4 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ jobs:
strategy:
matrix:
python-version: ["pypy3.10", "3.10"] # Arbitrary pick of one pypy and one Cpython version

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup cache for apt packages (used by builddeb)
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: debhelper (>= 8.0.0) dh-python python3-pytest libboost-regex-dev
version: 1.0
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -38,6 +42,7 @@ jobs:
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude examples/
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude examples/
- name: Build debian packages
run: make builddeb
- name: Test with pytest
run: |
pytest
run: pytest
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
recursive-include problemtools/config *
recursive-include problemtools/templates *
recursive-include problemtools/tests *
recursive-include examples *
recursive-include support *
1 change: 1 addition & 0 deletions problemtools/tests/hello/data/secret/hello.ans
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World!
Empty file.
8 changes: 8 additions & 0 deletions problemtools/tests/hello/input_validators/validate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python3
from sys import stdin
import sys

# There shouldn't be any input
assert len(stdin.readline()) == 0

sys.exit(42)
8 changes: 8 additions & 0 deletions problemtools/tests/hello/problem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source: Kattis
license: public domain

# Fix memory limit at 512 MB. (Note that for most problems, this
# should not be done. It is only done in this case because we include
# a test submission that goes over this limit.)
limits:
memory: 512
9 changes: 9 additions & 0 deletions problemtools/tests/hello/problem_statement/problem.en.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\problemname{Hello World!}

\section*{Input}

There is no input for this problem.

\section*{Output}

Output should contain one line, containing the string ``Hello World!''.
9 changes: 9 additions & 0 deletions problemtools/tests/hello/problem_statement/problem.sv.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\problemname{Hej Världen!}

\section*{Indata}

Detta problem har inget indata.

\section*{Output}

Utdata ska bestå av en rad, innehållandes strängen ``Hello World!''.
6 changes: 6 additions & 0 deletions problemtools/tests/hello/submissions/accepted/hello.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <cstdio>

int main(void) {
printf("Hello World!\n");
return 0;
}
5 changes: 5 additions & 0 deletions problemtools/tests/hello/submissions/accepted/hello.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class hello {
public static void main(String args[]) {
System.out.println("Hello World!");
}
}
4 changes: 4 additions & 0 deletions problemtools/tests/hello/submissions/accepted/hello.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fun main(args: Array<String>) {
val words = if (args.size == 0) arrayOf("Hello", "World!") else args
System.`out`.println(words.joinToString(separator = " "))
}
3 changes: 3 additions & 0 deletions problemtools/tests/hello/submissions/accepted/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python3

print('Hello World!')
35 changes: 35 additions & 0 deletions problemtools/tests/hello/submissions/accepted/hello_alarm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>

/* Based on the libc manual*/

/* This flag controls termination of the main loop. */
volatile sig_atomic_t keep_going = 1;

/* The signal handler just clears the flag and re-enables itself. */
void catch_alarm (int sig)
{
keep_going = 0;
signal (sig, catch_alarm);
}

void do_nothing (void)
{
int i=0;
for (i=0;i<1000;i+=1);
}

int main (void)
{
/* Establish a handler for SIGALRM signals. */
signal (SIGALRM, catch_alarm);
/* Set an alarm to go off in a little while. */
alarm (1);
/* Check the flag once in a while to see when to quit. */
while (keep_going)
do_nothing();

printf("Hello World!\n");
return EXIT_SUCCESS;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <iostream>
#include <algorithm>

int main(void) {
char *buf = new char[512*1024*1024]; // 512MB
buf[0] = 0;
for (int i = 1; i < 512*1024*1024; ++i)
buf[i] = 23*buf[i-1]+42;
std::cout << "Hello World!\n" << std::endl;
return 0;
}
6 changes: 6 additions & 0 deletions problemtools/tests/hello/submissions/wrong_answer/hello.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <cstdio>

int main(void) {
printf("Hello!");
return 0;
}
2 changes: 1 addition & 1 deletion problemtools/tests/test_verify_hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


def test_load_hello():
directory = pathlib.Path(__file__).parent.parent.parent / "examples" / "hello"
directory = pathlib.Path(__file__).parent / "hello"
string = str(directory.resolve())

args = verify.argparser().parse_args([string])
Expand Down

0 comments on commit ab2e34e

Please sign in to comment.