File tree Expand file tree Collapse file tree 13 files changed +98
-79
lines changed
Expand file tree Collapse file tree 13 files changed +98
-79
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ test.example:
99
1010test.01 :
1111 make test DAY=day-01
12+ test.02 :
13+ make test DAY=day-02
1214
1315#
1416# make docker.test DAY=<day>
@@ -21,14 +23,15 @@ test.01:
2123# Benefit 2: Reproduceability - Makes sure tests run with the same versions on any machine, regardless of what is installed on the host machine.
2224#
2325docker.test :
24- docker pull jonasjso/adventofcode2020:latest;
2526 docker run -ti --env DAY=$(DAY ) -v $(PWD ) :/test jonasjso/adventofcode2020:latest /bin/bash -c " cd /test && make test && exit"
2627
2728docker.example :
2829 make docker.test DAY=day-00-example
2930
3031docker.01 :
3132 make docker.test DAY=day-01
33+ docker.02 :
34+ make docker.test DAY=day-02
3235
3336docker.all :
3437 docker run -ti -v $(PWD ) :/test jonasjso/adventofcode2020:latest /bin/bash -c " cd /test && make && exit"
Original file line number Diff line number Diff line change @@ -33,7 +33,13 @@ Here you can see the status of automatic tests run by Github CI:
3333![ days/day-25] ( https://github.com/Arxcis/adventofcode2020/workflows/days/day-25/badge.svg )
3434![ days/day-00-example] ( https://github.com/Arxcis/adventofcode2020/workflows/days/day-00-example/badge.svg )
3535
36- ## Getting started if you are running Docker
36+ ## Example: Testing a single solution
37+
38+ ```
39+ ./scripts/test-rust.sh days/day-01 solutions/main.rs
40+ ```
41+
42+ ## Testing if you are running Docker
3743
3844If you are running docker, you can run tests inside a docker-container by doing:
3945```
@@ -42,8 +48,8 @@ make docker.01 // Expect to fail because we don't have any day-01 s
4248make docker.all // Expect some tests to succeed, some fail
4349```
4450
45- ## Getting started if you are not running Docker
46- If you are not running docker, you have to install languages we support on your host system. See the [ Dockerfile] ( ./Dockerfile ) for how you can do this on debian-based systems.
51+ ## Testing if you are not running Docker
52+ If you are not running docker, you have to install languages we support on your host system. See the [ Dockerfile] ( ./Dockerfile ) for how you can do this on debian-based systems.
4753
4854You can run the tests directly on your host system by doing:
4955```
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22set -e
33
4- DIR =$( dirname $( realpath $0 ) )
4+ D =$( dirname $( realpath $0 ) )
55
66# Run tests
7- $DIR /../../scripts/test-bash.sh $DIR " solutions/example.bash"
8- $DIR /../../scripts/test-c.sh $DIR " solutions/example.c"
9- $DIR /../../scripts/test-cpp.sh $DIR " solutions/example.cpp"
10- $DIR /../../scripts/test-go.sh $DIR " solutions/example.go"
11- $DIR /../../scripts/test-java.sh $DIR solutions Example
12- $DIR /../../scripts/test-node.sh $DIR " solutions/example.node.mjs"
13- $DIR /../../scripts/test-php.sh $DIR " solutions/example.php"
14- $DIR /../../scripts/test-py.sh $DIR " solutions/example.py"
15- $DIR /../../scripts/test-rust.sh $DIR " solutions/example.rs"
7+ $D /../../scripts/test-bash.sh $D /input.txt $D /output.txt $D / solutions/example.bash
8+ $D /../../scripts/test-c.sh $D /input.txt $D /output.txt $D / solutions/example.c
9+ $D /../../scripts/test-cpp.sh $D /input.txt $D /output.txt $D / solutions/example.cpp
10+ $D /../../scripts/test-go.sh $D /input.txt $D /output.txt $D / solutions/example.go
11+ $D /../../scripts/test-java.sh $D /input.txt $D /output.txt $D / solutions Example
12+ $D /../../scripts/test-node.sh $D /input.txt $D /output.txt $D / solutions/example.node.mjs
13+ $D /../../scripts/test-php.sh $D /input.txt $D /output.txt $D / solutions/example.php
14+ $D /../../scripts/test-py.sh $D /input.txt $D /output.txt $D / solutions/example.py
15+ $D /../../scripts/test-rust.sh $D /input.txt $D /output.txt $D / solutions/example.rs
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22set -e
33
4- # Usage: ./test-bash.sh DIR SOLUTION
5- # Example: ./test-bash.sh /day-03 solutions/main.bash
4+ # Usage: ./test-bash.sh INPUT OUTPUT SOLUTION
5+ # Example: ./test-bash.sh /day-03/input.txt /day-03/input.txt /day-03/ solutions/main.bash
66
7- DIR=" $1 "
8- SOLUTION=" $2 "
7+ INPUT=" $1 "
8+ OUTPUT=" $2 "
9+ SOLUTION=" $3 "
910
10- cat " $DIR /input.txt " | bash " $DIR / $ SOLUTION" | diff - " $DIR /output.txt "
11- echo " $DIR / bash $SOLUTION ✅"
11+ cat " $INPUT " | bash " $SOLUTION " | diff - " $OUTPUT "
12+ echo " cat INPUT | bash $SOLUTION ✅"
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22set -e
33
4- # Usage: .. /test-c.sh DIR SOLUTION
5- # Example: .. /test-c.sh /day-03 solutions/main.c
4+ # Usage: ./test-c.sh INPUT OUTPUT SOLUTION
5+ # Example: ./test-c.sh /day-03/input.txt /day-03/input.txt /day-03/ solutions/main.c
66
7- DIR=" $1 "
8- SOLUTION=" $2 "
9- OUT=" gcc.out"
7+ INPUT=" $1 "
8+ OUTPUT=" $2 "
9+ SOLUTION=" $3 "
10+ OUT=" /tmp/aoc2020.gcc.out"
1011
11- gcc " $DIR / $ SOLUTION" -o " $DIR / $ OUT" ;
12- cat " $DIR /input.txt " | " $DIR / $ OUT" | diff - " $DIR /output.txt "
13- rm " $DIR / $ OUT" ;
14- echo " $DIR / gcc $SOLUTION -o $OUT && ./ $OUT ✅"
12+ gcc $ SOLUTION -o $ OUT;
13+ cat $INPUT | $ OUT | diff - $OUTPUT
14+ rm $ OUT;
15+ echo " cat INPUT | gcc $SOLUTION ✅"
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22set -e
33
4- # Usage: .. /test-cpp.sh DIR SOLUTION
5- # Example: .. /test-cpp.sh /day-03 solutions/main.cpp
4+ # Usage: ./test-cpp.sh INPUT OUTPUT SOLUTION
5+ # Example: ./test-cpp.sh /day-03/input.txt /day-03/input.txt /day-03/ solutions/main.cpp
66
7- DIR=" $1 "
8- SOLUTION=" $2 "
9- OUT=" g++.out"
7+ INPUT=" $1 "
8+ OUTPUT=" $2 "
9+ SOLUTION=" $3 "
10+ OUT=" /tmp/aoc2020.g++.out"
1011
11- g++ " $DIR / $ SOLUTION" -o " $DIR / $ OUT" ;
12- cat " $DIR /input.txt " | " $DIR / $ OUT" | diff - " $DIR /output.txt "
13- rm " $DIR / $ OUT" ;
14- echo " $DIR / g++ $SOLUTION -o $OUT && ./ $OUT ✅"
12+ g++ $ SOLUTION -o $ OUT;
13+ cat $INPUT | $ OUT | diff - $OUTPUT
14+ rm $ OUT;
15+ echo " cat INPUT | g++ $SOLUTION ✅"
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22set -e
33
4- # Usage: .. /test-go.sh DIR SOLUTION
5- # Example: .. /test-go.sh /adventofcode2020/ day-03 solutions/main.go
4+ # Usage: ./test-go.sh INPUT OUTPUT SOLUTION
5+ # Example: ./test-go.sh /day-03/input.txt / day-03/input.txt /day-03/ solutions/main.go
66
7- DIR=" $1 "
8- SOLUTION=" $2 "
7+ INPUT=" $1 "
8+ OUTPUT=" $2 "
9+ SOLUTION=" $3 "
910
10- cat " $DIR /input.txt " | go run " $DIR / $ SOLUTION" | diff - " $DIR /output.txt "
11- echo " $DIR / go run $SOLUTION ✅"
11+ cat $INPUT | go run $ SOLUTION | diff - $OUTPUT
12+ echo " cat INPUT | go run $SOLUTION ✅"
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22set -e
33
4- # Usage: ../test-c.sh DIR SOLUTION_DIR JAVA_CLASSNAME
5- # Example: ../test-c.sh /day-03 solutions Main
4+ # Usage: ./test-java.sh INPUT OUTPUT SOLUTION_DIR JAVA_CLASSNAME
5+ # Example: ./test-java.sh /day-03/input.txt /day-03/input.txt /day-03/solutions Example
6+
7+ INPUT=" $1 "
8+ OUTPUT=" $2 "
9+ SOLUTION_DIR=" $3 "
10+ JAVA_CLASSNAME=" $4 "
611
7- DIR=" $1 "
8- SOLUTION_DIR=" $2 "
9- JAVA_CLASSNAME=" $3 "
1012JAVA_CLASSFILE=" $JAVA_CLASSNAME .class"
1113
12- cd " $DIR / $ SOLUTION_DIR"
14+ cd $ SOLUTION_DIR
1315javac " $JAVA_CLASSNAME .java"
14- cat " $DIR /input.txt " | java " $JAVA_CLASSNAME " | diff - " $DIR /output.txt "
16+ cat $INPUT | java $JAVA_CLASSNAME | diff - $OUTPUT
1517rm " $DIR /$SOLUTION_DIR /$JAVA_CLASSFILE " ;
16- echo " $DIR / javac $JAVA_CLASSNAME .java && java $JAVA_CLASSNAME ✅"
18+ echo " cat INPUT | javac $SOLUTION_DIR / $ JAVA_CLASSNAME .java ✅"
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22set -e
33
4- # Usage: .. /test-node.sh DIR SOLUTION
5- # Example: .. /test-node.sh /adventofcode2020/ day-03 solutions/main.node.mjs
4+ # Usage: ./test-node.sh INPUT OUTPUT SOLUTION
5+ # Example: ./test-node.sh /day-03/input.txt / day-03/input.txt /day-03/ solutions/main.node.mjs
66
7- DIR=" $1 "
8- SOLUTION=" $2 "
7+ INPUT=" $1 "
8+ OUTPUT=" $2 "
9+ SOLUTION=" $3 "
910
10- cat " $DIR /input.txt " | node " $DIR / $ SOLUTION" | diff - " $DIR /output.txt "
11- echo " $DIR / node $SOLUTION ✅"
11+ cat $INPUT | node $ SOLUTION | diff - $OUTPUT
12+ echo " cat INPUT | node $SOLUTION ✅"
You can’t perform that action at this time.
0 commit comments