-
-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit - based on standard project template
- Loading branch information
Sebastian Thiel
committed
Jun 7, 2018
0 parents
commit c3d319f
Showing
9 changed files
with
249 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,22 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
[*.sh] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
# Tab indentation (no size specified) | ||
[Makefile] | ||
indent_style = tab | ||
|
||
# Matches the exact files either package.json or .travis.yml | ||
[{package.json,.travis.yml}] | ||
indent_style = space | ||
indent_size = 2 |
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,16 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Rust template | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
/target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
/.idea/ | ||
|
||
/callgrind.profile |
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,17 @@ | ||
[package] | ||
name = "grit-cli" | ||
version = "1.0.0" | ||
authors = ["Sebastian Thiel <[email protected]>"] | ||
publish = false | ||
|
||
[dependencies] | ||
failure = "0.1.1" | ||
failure-tools = "4.0.2" | ||
|
||
[[bin]] | ||
name="grit" | ||
path="src/main.rs" | ||
|
||
[profile.release] | ||
panic = 'unwind' | ||
incremental = false |
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,43 @@ | ||
fixture = tests/fixtures/input.txt | ||
bench_fixture = tests/fixtures/big-input.txt | ||
docker_image = gitrs_docker_developer_environment | ||
|
||
help: | ||
$(info -Targets -----------------------------------------------------------------------------) | ||
$(info -- Use docker for all dependencies - run make interactively from there ----------------) | ||
$(info interactive-developer-environment-in-docker | gives you everything you need to run all targets) | ||
$(info -Development Targets -----------------------------------------------------------------) | ||
$(info lint | run lints with clippy) | ||
$(info benchmark | just for fun, really) | ||
$(info profile | only on linux - run callgrind and annotate it) | ||
$(info journey-tests | run all stateless journey test) | ||
$(info continuous-journey-tests | run all stateless journey test whenever something changes) | ||
|
||
always: | ||
|
||
interactive-developer-environment-in-docker: | ||
docker build -t $(docker_image) - < etc/developer.Dockerfile | ||
docker run -v $$PWD:/volume -w /volume -it $(docker_image) | ||
|
||
target/debug/rit: always | ||
cargo build | ||
|
||
target/release/rit: always | ||
cargo build --release | ||
|
||
lint: | ||
cargo clippy | ||
|
||
profile: target/release/rit | ||
valgrind --callgrind-out-file=callgrind.profile --tool=callgrind $< $(bench_fixture) >/dev/null | ||
callgrind_annotate --auto=yes callgrind.profile | ||
|
||
benchmark: target/release/rit | ||
hyperfine '$< $(bench_fixture)' | ||
|
||
journey-tests: target/debug/rit | ||
./tests/stateless-journey.sh $< | ||
|
||
continuous-journey-tests: | ||
watchexec $(MAKE) journey-tests | ||
|
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 @@ | ||
## Goal | ||
|
||
TBD |
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,8 @@ | ||
from guangie88/rustfmt-clippy:nightly | ||
|
||
run cargo install hyperfine watchexec | ||
|
||
run apt-get update | ||
run apt-get install -y valgrind | ||
|
||
env PATH=$PATH:/root/.cargo/bin |
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,4 @@ | ||
extern crate failure; | ||
extern crate failure_tools; | ||
|
||
fn main() {} |
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,14 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
exe=${1:?First argument must be the executable to test} | ||
|
||
root="$(cd "${0%/*}" && pwd)" | ||
# shellcheck disable=1090 | ||
source "$root/utilities.sh" | ||
snapshot="$root/snapshots" | ||
fixture="$root/fixtures" | ||
|
||
SUCCESSFULLY=0 | ||
WITH_FAILURE=1 | ||
|
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,122 @@ | ||
#!/bin/bash | ||
|
||
WHITE="$(tput setaf 9 2>/dev/null || echo -n '')" | ||
YELLOW="$(tput setaf 3 2>/dev/null || echo -n '')" | ||
GREEN="$(tput setaf 2 2>/dev/null || echo -n '')" | ||
RED="$(tput setaf 1 2>/dev/null || echo -n '')" | ||
OFFSET=( ) | ||
STEP=" " | ||
|
||
function title () { | ||
echo "$WHITE-----------------------------------------------------" | ||
echo "${GREEN}$*" | ||
echo "$WHITE-----------------------------------------------------" | ||
} | ||
|
||
function _context () { | ||
local name="${1:?}" | ||
shift | ||
echo 1>&2 "${YELLOW}${OFFSET[*]:-}[$name] $*" | ||
OFFSET+=("$STEP") | ||
} | ||
|
||
function with () { | ||
_context with "$*" | ||
} | ||
|
||
function when () { | ||
_context when "$*" | ||
} | ||
|
||
function _note () { | ||
local name="${1:?}" | ||
local color="${2:-}" | ||
shift 2 | ||
echo 1>&2 -n "${OFFSET[*]:-}${color}[$name] ${*// /}" | ||
} | ||
|
||
function it () { | ||
_note it "${GREEN}" "$*" | ||
} | ||
|
||
function precondition () { | ||
_note precondition "${WHITE}" "$*" | ||
} | ||
|
||
function shortcoming () { | ||
_note shortcoming "${RED}" "$*" | ||
} | ||
|
||
function fail () { | ||
echo 1>&2 "${RED} $*" | ||
exit 1 | ||
} | ||
|
||
function sandbox () { | ||
sandbox_tempdir="$(mktemp -t sandbox.XXXXXX -d)" | ||
# shellcheck disable=2064 | ||
trap "popd >/dev/null" EXIT | ||
pushd "$sandbox_tempdir" >/dev/null \ | ||
|| fail "Could not change directory into temporary directory." | ||
|
||
local custom_init="${1:-}" | ||
if [ -n "$custom_init" ]; then | ||
eval "$custom_init" | ||
fi | ||
} | ||
|
||
function expect_equals () { | ||
expect_run 0 test "${1:?}" = "${2:?}" | ||
} | ||
|
||
function expect_exists () { | ||
expect_run 0 test -e "${1:?}" | ||
} | ||
|
||
function expect_run_sh () { | ||
expect_run "${1:?}" bash -c "${2:?}" | ||
} | ||
|
||
function expect_snapshot () { | ||
local expected=${1:?} | ||
local actual=${2:?} | ||
if ! [ -e "$expected" ]; then | ||
mkdir -p "${expected%/*}" | ||
cp -R "$actual" "$expected" | ||
fi | ||
expect_run 0 diff -r -N "$expected" "$actual" | ||
} | ||
|
||
function expect_run () { | ||
local expected_exit_code=$1 | ||
shift | ||
local output= | ||
set +e | ||
output="$("$@" 2>&1)" | ||
|
||
local actual_exit_code=$? | ||
if [[ "$actual_exit_code" == "$expected_exit_code" ]]; then | ||
if [[ -n "${WITH_SNAPSHOT-}" ]]; then | ||
local expected="$WITH_SNAPSHOT" | ||
if ! [ -f "$expected" ]; then | ||
mkdir -p "${expected%/*}" | ||
echo -n "$output" > "$expected" || exit 1 | ||
fi | ||
if ! diff "$expected" <(echo -n "$output"); then | ||
echo 1>&2 "${RED} - FAIL" | ||
echo 1>&2 "${WHITE}\$ $*" | ||
echo 1>&2 "Output snapshot did not match snapshot at '$expected'" | ||
echo 1>&2 "$output" | ||
exit 1 | ||
fi | ||
fi | ||
echo 1>&2 | ||
else | ||
echo 1>&2 "${RED} - FAIL" | ||
echo 1>&2 "${WHITE}\$ $*" | ||
echo 1>&2 "${RED}Expected actual status $actual_exit_code to be $expected_exit_code" | ||
echo 1>&2 "$output" | ||
exit 1 | ||
fi | ||
set -e | ||
} |