Skip to content

Commit 1b4c441

Browse files
committed
Move strategy tests to a new directory, and add an astyle precommit hook.
1 parent cdf6196 commit 1b4c441

12 files changed

+41
-7
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ add_library(quadelect_lib src/tools/tools.cc
146146
src/bandit/bandit.cc
147147
src/bandit/binomial.cc
148148
src/bandit/lilucb.cc
149-
src/main/strat_test.cc
149+
src/tests/strategies.cc
150150
src/modes/breg.cc
151151
src/images/color/color.cc
152152
src/modes/yee.cc

astyle.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/bin/sh
2+
13
# Java brace style, C/C++ code, forced tab indentation, 75 character
24
# lines, indent (not align) after parens, align references to middle,
35
# put braces around one-liners, indent classes and case switches,

hooks/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This directory contains the pre-commit hook that runs Artistic Style before
2+
committing new code, to enforce a (mostly) uniform code standard.
3+
4+
Use the `./init_hook.sh` command from the repo root to install the hook into
5+
.git/hooks.

hooks/pre-commit

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
3+
# Most of this code is from
4+
# https://github.com/mellowcandle/astyle_precommit_hook/blob/master/pre-commit
5+
6+
if git rev-parse --verify HEAD >/dev/null 2>&1
7+
then
8+
against=HEAD
9+
else
10+
# Initial commit: diff against an empty tree object
11+
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
12+
fi
13+
14+
files=$(git diff-index --diff-filter=ACMR --name-only -r --cached $against -- | grep -i '\.c$\|\.cc$\|\.cpp$\|\.hpp$\|\.h$')
15+
for file in $files; do
16+
x=`echo $file`
17+
if test "x$x" != "x"; then
18+
./astyle.sh $file
19+
git add $file
20+
fi
21+
done

init_hook.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
echo Setting up pre-commit hook...
4+
5+
cd .git/hooks/
6+
ln -s ../../hooks/pre-commit ./pre-commit

src/main/test_brute_properties.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#include "../random/random.h"
3333

34-
#include "strat_test.h"
34+
#include "../tests/strategies.h"
3535

3636
int main(int argc, const char ** argv) {
3737
if (argc < 2) {

src/main/test_strategy_brute_bandit.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666

6767
#include "../bandit/tests/reverse.h"
6868

69-
#include "strat_test.h"
69+
#include "../tests/strategies.h"
7070

7171
// Testing JGA's "strategic manipulation possible" concept. Perhaps it should
7272
// be put into ttetest instead. "A method is vulnerable to burial if, when X

src/main/test_strategy_brute_detail.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
#include "../singlewinner/young.h"
6262

63-
#include "strat_test.h"
63+
#include "../tests/strategies.h"
6464

6565
// default values for number of processors and current processor
6666
// use -I compiler options to get multiproc support. TODO: make this an

src/main/test_strategy_fixed.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
#include "../bandit/bandit.h"
6161
#include "../bandit/lilucb.h"
6262

63-
#include "strat_test.h"
63+
#include "../tests/strategies.h"
6464

6565
// default values for number of processors and current processor
6666
// use -I compiler options to get multiproc support. TODO: make this an

src/main/test_strategy_linbrute_bandit.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
#include "../bandit/tests/reverse.h"
6666

67-
#include "strat_test.h"
67+
#include "../tests/strategies.h"
6868

6969
// Testing JGA's "strategic manipulation possible" concept. Perhaps it should
7070
// be put into ttetest instead. "A method is vulnerable to burial if, when X

0 commit comments

Comments
 (0)