trackler 2.0.6.34 → 2.0.6.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/common/exercises/change/canonical-data.json +6 -0
- data/common/exercises/luhn/canonical-data.json +35 -0
- data/common/exercises/rotational-cipher/cannonical-data.json +70 -0
- data/common/exercises/rotational-cipher/description.md +30 -0
- data/common/exercises/rotational-cipher/metadata.yml +4 -0
- data/common/exercises/run-length-encoding/description.md +7 -1
- data/lib/trackler/version.rb +1 -1
- data/tracks/elixir/exercises/run-length-encoding/example.exs +15 -4
- data/tracks/elixir/exercises/run-length-encoding/rle.exs +2 -2
- data/tracks/elixir/exercises/run-length-encoding/rle_test.exs +28 -11
- data/tracks/go/exercises/bob/bob_test.go +4 -1
- data/tracks/go/exercises/bracket-push/bracket_push_test.go +5 -2
- data/tracks/go/exercises/circular-buffer/circular_buffer_test.go +6 -6
- data/tracks/go/exercises/clock/clock_test.go +4 -1
- data/tracks/go/exercises/connect/connect_test.go +4 -1
- data/tracks/go/exercises/crypto-square/crypto_square_test.go +5 -2
- data/tracks/go/exercises/luhn/luhn_test.go +1 -1
- data/tracks/javascript/exercises/leap/leap.js +1 -1
- data/tracks/julia/.travis.yml +0 -2
- data/tracks/julia/config.json +41 -0
- data/tracks/julia/exercises/custom-set/HINTS.md +1 -0
- data/tracks/julia/exercises/custom-set/custom-set.jl +0 -0
- data/tracks/julia/exercises/custom-set/example.jl +51 -0
- data/tracks/julia/exercises/custom-set/runtests.jl +200 -0
- data/tracks/julia/exercises/isogram/example.jl +11 -0
- data/tracks/julia/exercises/isogram/isogram.jl +3 -0
- data/tracks/julia/exercises/isogram/runtests.jl +35 -0
- data/tracks/julia/exercises/luhn/example.jl +16 -0
- data/tracks/julia/exercises/luhn/luhn.jl +0 -0
- data/tracks/julia/exercises/luhn/runtests.jl +31 -0
- data/tracks/julia/exercises/nucleotide-count/example.jl +8 -0
- data/tracks/julia/exercises/nucleotide-count/nucleotide-count.jl +3 -0
- data/tracks/julia/exercises/nucleotide-count/runtests.jl +19 -0
- data/tracks/kotlin/.travis.yml +9 -1
- data/tracks/kotlin/README.md +117 -11
- data/tracks/kotlin/bin/journey-test.sh +279 -0
- data/tracks/kotlin/docs/INSTALLATION.md +193 -97
- data/tracks/kotlin/docs/TESTS.md +72 -137
- data/tracks/kotlin/exercises/hello-world/GETTING_STARTED.md +50 -0
- data/tracks/kotlin/exercises/hello-world/TUTORIAL.md +693 -0
- data/tracks/kotlin/exercises/hello-world/src/example/kotlin/HelloWorld.kt +2 -30
- data/tracks/kotlin/exercises/hello-world/src/main/kotlin/HelloWorld.kt +2 -30
- data/tracks/kotlin/exercises/hello-world/src/test/kotlin/HelloWorldTest.kt +11 -19
- data/tracks/objective-c/circle.yml +1 -1
- data/tracks/perl6/exercises/atbash-cipher/{cipher.t → atbash-cipher.t} +0 -0
- data/tracks/perl6/exercises/linked-list/linked-list.t +0 -0
- data/tracks/perl6/exercises/phone-number/{phone.t → phone-number.t} +0 -0
- data/tracks/perl6/exercises/rna-transcription/{rna_transcription.t → rna-transcription.t} +0 -0
- data/tracks/perl6/exercises/robot-name/{robot.t → robot-name.t} +0 -0
- data/tracks/perl6/exercises/scrabble-score/{scrabble_score.t → scrabble-score.t} +0 -0
- data/tracks/perl6/exercises/word-count/{word_count.t → word-count.t} +0 -0
- data/tracks/pony/config.json +9 -0
- data/tracks/pony/exercises/pascals-triangle/example.pony +18 -0
- data/tracks/pony/exercises/pascals-triangle/test.pony +31 -0
- data/tracks/r/config.json +20 -0
- data/tracks/r/exercises/grains/example.R +16 -0
- data/tracks/r/exercises/grains/grains.R +7 -0
- data/tracks/r/exercises/grains/test_grains.R +49 -0
- data/tracks/r/exercises/phone-number/example.R +30 -0
- data/tracks/r/exercises/phone-number/phone-number.R +3 -0
- data/tracks/r/exercises/phone-number/test_phone-number.R +44 -0
- data/tracks/r/exercises/secret-handshake/example.R +26 -0
- data/tracks/r/exercises/secret-handshake/secret-handshake.R +3 -0
- data/tracks/r/exercises/secret-handshake/test_secret-handshake.R +52 -0
- data/tracks/r/exercises/sieve/example.R +16 -0
- data/tracks/r/exercises/sieve/sieve.R +3 -0
- data/tracks/r/exercises/sieve/test_sieve.R +37 -0
- data/tracks/rust/config.json +11 -0
- data/tracks/rust/exercises/rotational-cipher/Cargo.lock +4 -0
- data/tracks/rust/exercises/rotational-cipher/Cargo.toml +4 -0
- data/tracks/rust/exercises/rotational-cipher/example.rs +16 -0
- data/tracks/rust/exercises/rotational-cipher/tests/rotational-cipher.rs +61 -0
- data/tracks/swift/circle.yml +6 -0
- metadata +46 -8
@@ -0,0 +1,19 @@
|
|
1
|
+
using Base.Test
|
2
|
+
|
3
|
+
include("nucleotide-count.jl")
|
4
|
+
|
5
|
+
@testset "empty strand" begin
|
6
|
+
@test count_nucleotides("") == Dict('A' => 0, 'C' => 0, 'G' => 0, 'T' => 0)
|
7
|
+
end
|
8
|
+
|
9
|
+
@testset "strand with repeated nucleotide" begin
|
10
|
+
@test count_nucleotides("GGGGGGG") == Dict('A' => 0, 'C' => 0, 'G' => 7, 'T' => 0)
|
11
|
+
end
|
12
|
+
|
13
|
+
@testset "strand with multiple nucleotides" begin
|
14
|
+
@test count_nucleotides("AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC") == Dict('A' => 20, 'C' => 12, 'G' => 17, 'T' => 21)
|
15
|
+
end
|
16
|
+
|
17
|
+
@testset "strand with invalid nucleotides" begin
|
18
|
+
@test_throws ErrorException count_nucleotides("AGXXACT")
|
19
|
+
end
|
data/tracks/kotlin/.travis.yml
CHANGED
@@ -3,8 +3,16 @@ language: java
|
|
3
3
|
jdk:
|
4
4
|
- oraclejdk8
|
5
5
|
|
6
|
-
# http://docs.travis-ci.com/user/migrating-from-legacy
|
7
6
|
sudo: false
|
7
|
+
cache: bundler
|
8
|
+
addons:
|
9
|
+
apt:
|
10
|
+
packages:
|
11
|
+
- tree
|
12
|
+
before_install:
|
13
|
+
- rvm install 2.2.5
|
14
|
+
- rvm use 2.2.5
|
8
15
|
|
9
16
|
script:
|
10
17
|
- bin/unit-tests.sh
|
18
|
+
- bin/journey-test.sh
|
data/tracks/kotlin/README.md
CHANGED
@@ -1,20 +1,126 @@
|
|
1
|
-
#
|
1
|
+
# xkotlin [](https://travis-ci.org/exercism/xkotlin)
|
2
2
|
|
3
|
-
Exercism
|
3
|
+
Source for Exercism Exercises in Kotlin.
|
4
4
|
|
5
|
-
##
|
5
|
+
## Contributing Guide
|
6
6
|
|
7
|
-
|
7
|
+
For general information about how to contribute to Exercism, please refer to the [Contributing Guide](https://github.com/exercism/x-api/blob/master/CONTRIBUTING.md#the-exercise-data).
|
8
8
|
|
9
|
-
##
|
9
|
+
## Table of Contents
|
10
10
|
|
11
|
-
|
11
|
+
* [Overview](#overview)
|
12
|
+
* [Contributing With Minimal Setup](#contributing-with-minimal-setup)
|
13
|
+
* [Getting Familiar With the Codebase](#getting-familiar-with-the-codebase)
|
14
|
+
* [The `exercises` Module](#the-exercises-module)
|
15
|
+
* [The Problem Submodules](#the-problem-submodules)
|
16
|
+
* [Advanced: Complete Local Setup](#advanced-complete-local-setup)
|
17
|
+
* [Tip: `gradle clean` before `exercism fetch`](#tip-gradle-clean-before-exercism-fetch)
|
12
18
|
|
13
|
-
## License
|
14
19
|
|
15
|
-
|
20
|
+
## Overview
|
21
|
+
|
22
|
+
This guide covers contributing to the Kotlin track. If you are new, this guide is for you.
|
23
|
+
|
24
|
+
If, at any point, you're having any trouble, pop in the [Gitter exercism/dev room](https://gitter.im/exercism/dev) for help.
|
25
|
+
|
26
|
+
## Contributing With Minimal Setup
|
27
|
+
|
28
|
+
First things first: by contributing to Exercism, you are making this learning tool that much better and improving our industry as a whole... thank you!!!
|
29
|
+
|
30
|
+
To submit a fix for an existing exercise or port an exercise to Kotlin with the least amount of setup:
|
31
|
+
|
32
|
+
1. **Ensure you have the basic Java tooling installed:** JDK 1.8+, an editor and Gradle 2.x.
|
33
|
+
|
34
|
+
(see [exercism.io: Installing Kotlin](http://exercism.io/languages/kotlin/installing))
|
35
|
+
- **Setup a branch on a fork of [exercism/xkotlin](https://github.com/exercism/xkotlin) on your computer.**
|
36
|
+
|
37
|
+
See [GitHub Help: Forking](https://help.github.com/articles/fork-a-repo/). Use those instructions (in conjunction with [Exercism Contributing Guide](https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md#git-basics)) to:
|
38
|
+
* "fork" a repository on GitHub;
|
39
|
+
- install `git`;
|
40
|
+
- "clone" a copy of your fork;
|
41
|
+
- configure an "upstream remote" (in this case, `exercism/xkotlin`);
|
42
|
+
- create a branch to house your work
|
43
|
+
- **Write the codes.** Do your work on that branch you just created.
|
44
|
+
|
45
|
+
The [Getting Familiar With the Codebase](#getting-familiar-with-the-codebase) section, below, is an orientation.
|
46
|
+
- **Commit, push and create a pull request.**
|
47
|
+
|
48
|
+
Something like:
|
49
|
+
```
|
50
|
+
$ git add .
|
51
|
+
$ git commit -m "(An intention-revealing commit message)"
|
52
|
+
$ git push
|
53
|
+
```
|
54
|
+
|
55
|
+
[Exercism Contributing Guide :: Commit Messages](https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md#commit-messages) provides practical advice on crafting meaningful commit messages.
|
56
|
+
- **Verify that your work passes all tests.** When you create a pull request (PR), GitHub triggers a build on Travis CI. Your PR will not be merged unless those tests pass.
|
57
|
+
|
58
|
+
## Getting Familiar With the Codebase
|
59
|
+
|
60
|
+
There are two objectives to the design of this build:
|
61
|
+
|
62
|
+
1. when a problem is built from within the xkotlin repo (i.e. when you, the contributor, are developing the exercise), the tests run against the "example" code;
|
63
|
+
2. when a problem is built outside the xkotlin repo (when a participant is solving the exercise), the tests run against the "main" code.
|
64
|
+
|
65
|
+
This repo is a multi-project gradle build.
|
66
|
+
|
67
|
+
### The `exercises` Module
|
68
|
+
|
69
|
+
This is the top-level module, contained in the `exercises` directory. It is a container for the problem sub-modules.
|
16
70
|
|
17
|
-
|
71
|
+
* it's `build.gradle` points the "main" sourceset to the example code.
|
72
|
+
* it's `settings.gradle` names each of the subprojects, one for each problem in the set.
|
73
|
+
|
74
|
+
### The Problem Submodules
|
75
|
+
|
76
|
+
The `exercises` subdirectory contains all of the problem submodules.
|
77
|
+
Each problem/submodule is a subdirectory of the same name as its slug.
|
78
|
+
|
79
|
+
* it's `build.gradle` names dependencies required to work that problem.
|
80
|
+
|
81
|
+
Each problem/submodule has three source sets:
|
82
|
+
|
83
|
+
* `src/test/kotlin/` — a test suite defining the edges of the problem
|
84
|
+
* `src/example/kotlin/` — an example solution that passes all the tests
|
85
|
+
* `src/main/kotlin/` — starter source files, if required/desired *(this directory usually only has a `.keep` file in it)*.
|
86
|
+
|
87
|
+
----
|
88
|
+
|
89
|
+
## Advanced: Complete Local Setup
|
90
|
+
|
91
|
+
If you are going to make significant contribution(s) to the track, you might find it handy to have a complete local install of exercism on your computer. This way, you can run the full suite of tests without having to create/update a PR.
|
92
|
+
|
93
|
+
The easiest way to achieve this is simply use the `bin/journey-test.sh` script. However, you may want to perform other tests, depending on what you are doing. You can do so by duplicating the setup performed by the `bin/journey-test.sh` script.
|
94
|
+
|
95
|
+
### Tip: `gradle clean` before `exercism fetch`
|
96
|
+
|
97
|
+
If you `exercism fetch` after doing a build, the CLI will fail with the following error message:
|
98
|
+
|
99
|
+
```
|
100
|
+
$ exercism fetch kotlin bob
|
101
|
+
2015/09/06 15:03:21 an internal server error was received.
|
102
|
+
Please file a bug report with the contents of 'exercism debug' at: https://github.com/exercism/exercism.io/issues
|
103
|
+
```
|
104
|
+
|
105
|
+
and if you review the logs of your x-api, you'll find:
|
106
|
+
|
107
|
+
```
|
108
|
+
127.0.0.1 - - [06/Sep/2015:15:20:56 -0700] "GET /v2/exercises/kotlin/bob HTTP/1.1" 500 514949 0.2138
|
109
|
+
2015-09-06 15:21:01 - JSON::GeneratorError - source sequence is illegal/malformed utf-8:
|
110
|
+
```
|
111
|
+
|
112
|
+
This is because some files generated by the build can't be served from the x-api. This is by design: the CLI does not serve binaries. To fix this, simply make sure you do a clean in your `xkotlin` repo before you fetch:
|
113
|
+
|
114
|
+
```
|
115
|
+
cd ~/workspace/exercism/xkotlin/exercises
|
116
|
+
gradle clean
|
117
|
+
cd ~/workspace/exercism/exercises
|
118
|
+
exercism fetch kotlin bob
|
119
|
+
```
|
120
|
+
|
121
|
+
|
122
|
+
# License
|
123
|
+
|
124
|
+
The MIT License (MIT)
|
18
125
|
|
19
|
-
|
20
|
-
The Kotlin icon was designed by JetBrains and may be used in its original form.
|
126
|
+
Copyright (c) 2014 Katrina Owen, _@kytrinyx.com
|
@@ -0,0 +1,279 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This script is shared between the Java and Kotlin tracks. If you make an update to this script on
|
4
|
+
# on track, please create a companion PR to merge it in to the other. Thank you!
|
5
|
+
TRACK=kotlin
|
6
|
+
TRACK_REPO="x${TRACK}"
|
7
|
+
TRACK_SRC_EXT="kt"
|
8
|
+
|
9
|
+
on_exit() {
|
10
|
+
echo ">>> on_exit()"
|
11
|
+
if [[ "$xapi_pid" != "" ]] ; then
|
12
|
+
kill $xapi_pid
|
13
|
+
echo "stopped x-api (pid=${xapi_pid})"
|
14
|
+
fi
|
15
|
+
cd $EXECPATH
|
16
|
+
echo "<<< on_exit()"
|
17
|
+
}
|
18
|
+
|
19
|
+
assert_installed() {
|
20
|
+
local binary=$1
|
21
|
+
echo ">>> assert_installed(binary=\"${binary}\")"
|
22
|
+
|
23
|
+
if [[ "`which $binary`" == "" ]]; then
|
24
|
+
echo "${binary} not found; it is required to perform this test."
|
25
|
+
echo -e "Have you completed the setup instructions at https://github.com/exercism/${TRACK_REPO} ?\n"
|
26
|
+
echo "PATH=${PATH}"
|
27
|
+
echo "aborting."
|
28
|
+
exit 1
|
29
|
+
fi
|
30
|
+
echo "<<< assert_installed()"
|
31
|
+
}
|
32
|
+
|
33
|
+
assert_ruby_installed() {
|
34
|
+
local ruby_app_home="$1"
|
35
|
+
echo ">>> assert_ruby_installed(ruby_app_home=\"${ruby_app_home}\")"
|
36
|
+
|
37
|
+
pushd "${ruby_app_home}"
|
38
|
+
local current_ruby_ver=`ruby --version | egrep --only-matching "[0-9]+\.[0-9]+\.[0-9]+"`
|
39
|
+
local expected_ruby_ver=`cat Gemfile | awk -F\' '/ruby /{print $2}'`
|
40
|
+
popd
|
41
|
+
if [[ "${expected_ruby_ver}" != "" && "${current_ruby_ver}" != "${expected_ruby_ver}" ]]; then
|
42
|
+
echo "${ruby_app_home} requires Ruby ${expected_ruby_ver}; current Ruby version is ${current_ruby_ver}."
|
43
|
+
echo -e "Ruby used: `which ruby`.\n"
|
44
|
+
echo -e "Have you completed the setup instructions at https://github.com/exercism/${TRACK_REPO} ?\n"
|
45
|
+
echo "PATH=${PATH}"
|
46
|
+
echo "aborting."
|
47
|
+
exit 1
|
48
|
+
fi
|
49
|
+
echo "<<< assert_ruby_installed()"
|
50
|
+
}
|
51
|
+
|
52
|
+
clean() {
|
53
|
+
local build_dir="$1"
|
54
|
+
echo ">>> clean(build_dir=\"${build_dir}\")"
|
55
|
+
|
56
|
+
# empty, absolute path, or parent reference are considered dangerous to rm -rf against.
|
57
|
+
if [[ "${build_dir}" == "" || ${build_dir} =~ ^/ || ${build_dir} =~ \.\. ]] ; then
|
58
|
+
echo "Value for build_dir looks dangerous. Aborting."
|
59
|
+
exit 1
|
60
|
+
fi
|
61
|
+
|
62
|
+
local build_path=$( pwd )/${build_dir}
|
63
|
+
if [[ -d "${build_path}" ]] ; then
|
64
|
+
echo "Cleaning journey script build output directory (${build_path})."
|
65
|
+
rm -rf "${build_path}"
|
66
|
+
fi
|
67
|
+
cd exercises
|
68
|
+
gradle clean
|
69
|
+
cd ..
|
70
|
+
echo "<<< clean()"
|
71
|
+
}
|
72
|
+
|
73
|
+
get_operating_system() {
|
74
|
+
case $(uname) in
|
75
|
+
(Darwin*)
|
76
|
+
echo "mac";;
|
77
|
+
(Linux*)
|
78
|
+
echo "linux";;
|
79
|
+
(Windows*)
|
80
|
+
echo "windows";;
|
81
|
+
(*)
|
82
|
+
echo "linux";;
|
83
|
+
esac
|
84
|
+
}
|
85
|
+
|
86
|
+
get_cpu_architecture() {
|
87
|
+
case $(uname -m) in
|
88
|
+
(*64*)
|
89
|
+
echo 64bit;;
|
90
|
+
(*686*)
|
91
|
+
echo 32bit;;
|
92
|
+
(*386*)
|
93
|
+
echo 32bit;;
|
94
|
+
(*)
|
95
|
+
echo 64bit;;
|
96
|
+
esac
|
97
|
+
}
|
98
|
+
|
99
|
+
download_exercism_cli() {
|
100
|
+
local os="$1"
|
101
|
+
local arch="$2"
|
102
|
+
local exercism_home="$3"
|
103
|
+
echo ">>> download_exercism_cli(os=\"${os}\", arch=\"${arch}\", exercism_home=\"${exercism_home}\")"
|
104
|
+
|
105
|
+
local CLI_RELEASES=https://github.com/exercism/cli/releases
|
106
|
+
|
107
|
+
local latest=${CLI_RELEASES}/latest
|
108
|
+
# "curl..." :: HTTP 302 headers, including "Location" -- URL to redirect to.
|
109
|
+
# "awk..." :: pluck last path segment from "Location" (i.e. the version number)
|
110
|
+
local version="$(curl --head --silent ${latest} | awk -v FS=/ '/Location:/{print $NF}' | tr -d '\r')"
|
111
|
+
local download_url=${CLI_RELEASES}/download/${version}/exercism-${os}-${arch}.tgz
|
112
|
+
|
113
|
+
mkdir -p ${exercism_home}
|
114
|
+
curl -s --location ${download_url} | tar xz -C ${exercism_home}
|
115
|
+
echo "<<< download_exercism_cli()"
|
116
|
+
}
|
117
|
+
|
118
|
+
git_clone() {
|
119
|
+
local repo_name="$1"
|
120
|
+
local dest_path="$2"
|
121
|
+
echo ">>> git_clone(repo_name=\"${repo_name}\", dest_path=\"${dest_path}\")"
|
122
|
+
|
123
|
+
git clone https://github.com/exercism/${repo_name} ${dest_path}
|
124
|
+
|
125
|
+
echo "<<< git_clone()"
|
126
|
+
}
|
127
|
+
|
128
|
+
make_local_trackler() {
|
129
|
+
local trackler="$1"
|
130
|
+
local xapi_home="$2"
|
131
|
+
echo ">>> make_local_trackler(trackler=\"${trackler}\", xapi_home=\"${xapi_home}\")"
|
132
|
+
|
133
|
+
local track_root=$( pwd )
|
134
|
+
pushd ${trackler}
|
135
|
+
git submodule init -- common
|
136
|
+
git submodule update
|
137
|
+
|
138
|
+
# Bake in local copy of this track; this is what we are testing.
|
139
|
+
rmdir tracks/${TRACK}
|
140
|
+
mkdir -p tracks/${TRACK}/exercises
|
141
|
+
cp ${track_root}/config.json tracks/${TRACK}
|
142
|
+
cp -r ${track_root}/exercises tracks/${TRACK}
|
143
|
+
|
144
|
+
# Set the version to that expected by x-api
|
145
|
+
version=$( grep -m 1 'trackler' ${xapi_home}/Gemfile.lock | sed 's/.*(//' | sed 's/)//' )
|
146
|
+
echo "module Trackler VERSION = \"${version}\" end" > lib/trackler/version.rb
|
147
|
+
|
148
|
+
gem install bundler
|
149
|
+
bundle install
|
150
|
+
gem build trackler.gemspec
|
151
|
+
|
152
|
+
# Make *this* the gem that x-api uses when we build x-api.
|
153
|
+
gem install --local trackler-*.gem
|
154
|
+
|
155
|
+
popd > /dev/null
|
156
|
+
echo "<<< make_local_trackler()"
|
157
|
+
}
|
158
|
+
|
159
|
+
start_x_api() {
|
160
|
+
local xapi_home="$1"
|
161
|
+
echo ">>> start_x_api(xapi_home=\"${xapi_home}\")"
|
162
|
+
|
163
|
+
pushd $xapi_home
|
164
|
+
|
165
|
+
gem install bundler
|
166
|
+
bundle install
|
167
|
+
RACK_ENV=development rackup &
|
168
|
+
xapi_pid=$!
|
169
|
+
sleep 5
|
170
|
+
|
171
|
+
echo "x-api is running (pid=${xapi_pid})."
|
172
|
+
|
173
|
+
popd > /dev/null
|
174
|
+
echo "<<< start_x_api()"
|
175
|
+
}
|
176
|
+
|
177
|
+
configure_exercism_cli() {
|
178
|
+
local exercism_home="$1"
|
179
|
+
local exercism_configfile="$2"
|
180
|
+
local xapi_port=$3
|
181
|
+
echo ">>> configure_exercism_cli(exercism_home=\"${exercism_home}\", exercism_configfile=\"${exercism_configfile}\", xapi_port=${xapi_port})"
|
182
|
+
local exercism="./exercism --config ${exercism_configfile}"
|
183
|
+
|
184
|
+
mkdir -p "${exercism_home}"
|
185
|
+
pushd "${exercism_home}"
|
186
|
+
$exercism configure --dir="${exercism_home}"
|
187
|
+
$exercism configure --api http://localhost:${xapi_port}
|
188
|
+
$exercism debug
|
189
|
+
popd
|
190
|
+
|
191
|
+
echo "<<< configure_exercism_cli()"
|
192
|
+
}
|
193
|
+
|
194
|
+
solve_all_exercises() {
|
195
|
+
local exercism_exercises_dir="$1"
|
196
|
+
local exercism_configfile="$2"
|
197
|
+
echo ">>> solve_all_exercises(exercism_exercises_dir=\"${exercism_exercises_dir}\", exercism_configfile=\"${exercism_configfile}\")"
|
198
|
+
|
199
|
+
local track_root=$( pwd )
|
200
|
+
local exercism_cli="./exercism --config ${exercism_configfile}"
|
201
|
+
local exercises=`cat config.json | jq '.exercises[] .slug' --raw-output`
|
202
|
+
local total_exercises=`cat config.json | jq '.exercises | length'`
|
203
|
+
local current_exercise_number=1
|
204
|
+
local tempfile="${TMPDIR:-/tmp}/journey-test.sh-unignore_all_tests.txt"
|
205
|
+
|
206
|
+
pushd ${exercism_exercises_dir}
|
207
|
+
for exercise in $exercises; do
|
208
|
+
echo -e "\n\n"
|
209
|
+
echo "=================================================="
|
210
|
+
echo "${current_exercise_number} of ${total_exercises} -- ${exercise}"
|
211
|
+
echo "=================================================="
|
212
|
+
|
213
|
+
${exercism_cli} fetch ${TRACK} $exercise
|
214
|
+
cp -R -H ${track_root}/exercises/${exercise}/src/example/${TRACK}/* ${exercism_exercises_dir}/${TRACK}/${exercise}/src/main/${TRACK}/
|
215
|
+
|
216
|
+
pushd ${exercism_exercises_dir}/${TRACK}/${exercise}
|
217
|
+
# Ensure we run all the tests (as delivered, all but the first is @Ignore'd)
|
218
|
+
for testfile in `find . -name "*Test.${TRACK_SRC_EXT}"`; do
|
219
|
+
sed 's/@Ignore//' ${testfile} > "${tempfile}" && mv "${tempfile}" "${testfile}"
|
220
|
+
done
|
221
|
+
gradle test
|
222
|
+
popd
|
223
|
+
|
224
|
+
current_exercise_number=$((current_exercise_number + 1))
|
225
|
+
done
|
226
|
+
popd
|
227
|
+
}
|
228
|
+
|
229
|
+
main() {
|
230
|
+
# all functions assume current working directory is repository root.
|
231
|
+
cd "${SCRIPTPATH}/.."
|
232
|
+
|
233
|
+
local track_root=$( pwd )
|
234
|
+
local build_dir="build"
|
235
|
+
local build_path="${track_root}/${build_dir}"
|
236
|
+
|
237
|
+
local xapi_home="${build_path}/x-api"
|
238
|
+
local trackler_home="${build_path}/trackler"
|
239
|
+
local exercism_home="${build_path}/exercism"
|
240
|
+
|
241
|
+
local exercism_configfile=".journey-test.exercism.json"
|
242
|
+
local xapi_port=9292
|
243
|
+
|
244
|
+
assert_installed "gradle"
|
245
|
+
assert_installed "jq"
|
246
|
+
|
247
|
+
clean "${build_dir}"
|
248
|
+
|
249
|
+
# Make a local version of trackler that includes the source from this repo.
|
250
|
+
git_clone "x-api" "${xapi_home}"
|
251
|
+
git_clone "trackler" "${trackler_home}"
|
252
|
+
assert_ruby_installed "${trackler_home}"
|
253
|
+
make_local_trackler "${trackler_home}" "${xapi_home}"
|
254
|
+
|
255
|
+
# Stand-up a local instance of x-api so we can fetch the exercises through it.
|
256
|
+
assert_ruby_installed "${xapi_home}"
|
257
|
+
start_x_api "${xapi_home}"
|
258
|
+
|
259
|
+
# Create a CLI install and config just for this build; this script does not use your CLI install.
|
260
|
+
download_exercism_cli $(get_operating_system) $(get_cpu_architecture) "${exercism_home}"
|
261
|
+
configure_exercism_cli "${exercism_home}" "${exercism_configfile}" "${xapi_port}"
|
262
|
+
|
263
|
+
solve_all_exercises "${exercism_home}" "${exercism_configfile}"
|
264
|
+
}
|
265
|
+
|
266
|
+
##########################################################################
|
267
|
+
# Execution begins here...
|
268
|
+
|
269
|
+
# If any command fails, fail the script.
|
270
|
+
set -ex
|
271
|
+
SCRIPTPATH=$( pushd `dirname $0` > /dev/null && pwd && popd > /dev/null )
|
272
|
+
EXECPATH=$( pwd )
|
273
|
+
# Make output easier to read in CI
|
274
|
+
TERM=dumb
|
275
|
+
|
276
|
+
xapi_pid=""
|
277
|
+
trap on_exit EXIT
|
278
|
+
main
|
279
|
+
|