-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to generate dummy exercises (solutions, tests and subjects) from provided templates
- Loading branch information
Showing
5 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Subject ${N} | ||
|
||
Some random text for subject ${N} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# dummy-ex-generator | ||
|
||
A simple script to generate solutions, tests and subjects for dummy exercises from provided templates. | ||
The script will create 3 directories in the working directory to store the dummy exercise solutions, tests and subjects. | ||
It is possible to change the number of exercises created by varying the `N` variable inside the script. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
# File: | ||
|
||
N_FILES=10 | ||
|
||
TEST_DIR='tests' | ||
SUBJECT_DIR='subjects' | ||
SOLUTIONS_DIR='solutions' | ||
|
||
TEST_TEMPLTATE='test-template.go' | ||
SUBJECT_TEMPLATE='README-template.md' | ||
SOLUTIONS_TEMPLATE='solution-template.go' | ||
|
||
mkdir -p $TEST_DIR | ||
mkdir -p $SUBJECT_DIR | ||
mkdir -p $SOLUTIONS_DIR | ||
|
||
fill_subjects() { | ||
TEMPLATE=$1 | ||
OUTDIR=$2 | ||
for N in $(seq 1 $N_FILES) | ||
do | ||
DIR="dummy$N" | ||
mkdir -p $OUTDIR/$DIR | ||
cat $TEMPLATE | sed "s|\${N}|$N|g" > "./$OUTDIR/$DIR/README.md" | ||
done | ||
} | ||
|
||
fill_solutions() { | ||
TEMPLATE=$1 | ||
OUTDIR=$2 | ||
for N in $(seq 1 $N_FILES) | ||
do | ||
DIR="dummy$N" | ||
mkdir -p $OUTDIR/$DIR | ||
cat $TEMPLATE | sed "s|\${N}|$N|g" > "./$OUTDIR/$DIR/main.go" | ||
done | ||
} | ||
|
||
fill_test() { | ||
TEMPLATE=$1 | ||
OUTDIR=$2 | ||
for N in $(seq 1 $N_FILES) | ||
do | ||
DIR="dummy$N""_test" | ||
mkdir -p $OUTDIR/$DIR | ||
cat $TEMPLATE | sed "s|\${N}|$N|g" > "./$OUTDIR/$DIR/main.go" | ||
done | ||
} | ||
|
||
fill_test $TEST_TEMPLTATE $TEST_DIR | ||
fill_subjects $SUBJECT_TEMPLATE $SUBJECT_DIR | ||
fill_solutions $SOLUTIONS_TEMPLATE $SOLUTIONS_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
fmt.Println("Hello World ${N}") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "github.com/01-edu/go-tests-training/lib/challenge" | ||
|
||
func main() { | ||
challenge.Program("dummy${N}") | ||
} |