Skip to content

Commit 36bda16

Browse files
authored
Merge pull request #209 from sourceryinstitute/small-tweaks
Increase coverage and git-hooks robustness
2 parents 09a1e30 + b8c336f commit 36bda16

File tree

8 files changed

+319
-117
lines changed

8 files changed

+319
-117
lines changed

Brewfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Brewfile to install OpenCoarrays prerequisites with [Homebrew] or [Linuxbrew].
2+
#
3+
# TL;DR: `brew tap homebrew/bundle && brew bundle` to install prerequisites
4+
#
5+
# Homebrew for Mac OS X can be installed via:
6+
# `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
7+
# Linux brew (lives in userland, no sudo required) can be installed with:
8+
# `ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/linuxbrew/go/install)"`
9+
#
10+
# Once Homebrew/Linuxbrew is installed, execute the following commands to install the required prerequisites:
11+
# `brew tap homebrew/bundle && brew bundle`
12+
#
13+
# NOTE: Until Linuxbrew upgrades to GCC 6.1 or later, you will have to edit the `mpich` line to:
14+
# `brew 'mpich', args: ['cc=gcc-5', 'cxx=g++-5']`
15+
16+
brew 'cmake'
17+
brew 'gcc'
18+
brew 'mpich', args: ['cc=gcc-6', 'cxx=g++-6']
19+
20+
# [Homebrew]: http://brew.sh
21+
# [Linuxbrew]: http://linuxbrew.sh

CMakeLists.txt

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,30 @@ add_custom_target ( uninstall
151151

152152
enable_testing()
153153

154+
# Determine if we're using Open MPI
155+
execute_process(COMMAND ${MPIEXEC} --version
156+
OUTPUT_VARIABLE mpi_version_out)
157+
if (mpi_version_out MATCHES "[Oo]pen[ -][Mm][Pp][Ii]")
158+
message( STATUS "OpenMPI detected")
159+
set ( openmpi true )
160+
endif ()
161+
162+
include( ProcessorCount )
163+
ProcessorCount(N)
154164
function(add_mpi_test name num_mpi_proc path)
155-
set(test_parameters ${MPIEXEC_NUMPROC_FLAG} ${num_mpi_proc} )
165+
if ( ((N LESS num_mpi_proc) OR (N EQUAL 0)) )
166+
message(STATUS "Test ${name} is oversubscribed: ${num_mpi_proc} ranks requested with ${N} system processor available.")
167+
if ( openmpi )
168+
if ( N LESS 2 )
169+
set( num_mpi_proc 2 )
170+
set (test_parameters --oversubscribed)
171+
else()
172+
set ( num_mpi_proc ${N} )
173+
endif()
174+
message( STATUS "Open-MPI detected, over-riding oversubscribed test, ${name}, with ${num_mpi_proc} ranks." )
175+
endif()
176+
endif()
177+
set(test_parameters ${test_parameters} ${MPIEXEC_NUMPROC_FLAG} ${num_mpi_proc} )
156178
add_test(NAME ${name} COMMAND ${MPIEXEC} ${test_parameters} "${path}")
157179
set_property(TEST ${name} PROPERTY PASS_REGULAR_EXPRESSION "Test passed.")
158180
endfunction(add_mpi_test)
@@ -180,7 +202,7 @@ if(opencoarrays_aware_compiler)
180202
add_mpi_test(syncimages 32 ${tests_root}/unit/sync/syncimages)
181203
add_mpi_test(duplicate_syncimages 8 ${tests_root}/unit/sync/duplicate_syncimages)
182204
add_mpi_test(co_reduce 4 ${tests_root}/unit/collectives/co_reduce_test)
183-
# add_mpi_test(syncimages_status 32 ${tests_root}/unit/sync/syncimages_status)
205+
add_mpi_test(syncimages_status 32 ${tests_root}/unit/sync/syncimages_status)
184206

185207
# Integration tests verifying the use of libcaf_mpi in applications
186208
add_mpi_test(hello_multiverse 2 ${tests_root}/integration/coarrayHelloWorld/hello_multiverse)

developer-scripts/Vagrantfile

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
VAGRANT_COMMAND = ARGV[0]
4+
5+
# All Vagrant configuration is done below. The "2" in Vagrant.configure
6+
# configures the configuration version (we support older styles for
7+
# backwards compatibility). Please don't change it unless you know what
8+
# you're doing.
9+
Vagrant.configure(2) do |config|
10+
# The most common configuration options are documented and commented below.
11+
# For a complete reference, please see the online documentation at
12+
# https://docs.vagrantup.com.
13+
14+
# Every Vagrant development environment requires a box. You can search for
15+
# boxes at https://atlas.hashicorp.com/search.
16+
config.vm.box = "hashicorp/precise64"
17+
18+
# Disable automatic box update checking. If you disable this, then
19+
# boxes will only be checked for updates when the user runs
20+
# `vagrant box outdated`. This is not recommended.
21+
config.vm.box_check_update = true
22+
23+
# Create a forwarded port mapping which allows access to a specific port
24+
# within the machine from a port on the host machine. In the example below,
25+
# accessing "localhost:8080" will access port 80 on the guest machine.
26+
# config.vm.network "forwarded_port", guest: 80, host: 8080
27+
28+
# Create a private network, which allows host-only access to the machine
29+
# using a specific IP.
30+
# config.vm.network "private_network", ip: "192.168.33.10"
31+
32+
# Create a public network, which generally matched to bridged network.
33+
# Bridged networks make the machine appear as another physical device on
34+
# your network.
35+
# config.vm.network "public_network"
36+
37+
# Share an additional folder to the guest VM. The first argument is
38+
# the path on the host to the actual folder. The second argument is
39+
# the path on the guest to mount the folder. And the optional third
40+
# argument is a set of non-required options.
41+
config.vm.synced_folder "..", "/home/travis/build/sourceryinstitute/opencoarrays", mount_options: ["dmode=2770", "fmode=660"]
42+
43+
44+
# Provider-specific configuration so you can fine-tune various
45+
# backing providers for Vagrant. These expose provider-specific options.
46+
# Example for VirtualBox:
47+
#
48+
# config.vm.provider "virtualbox" do |vb|
49+
# # Display the VirtualBox GUI when booting the machine
50+
# vb.gui = true
51+
#
52+
# # Customize the amount of memory on the VM:
53+
# vb.memory = "1024"
54+
# end
55+
#
56+
# View the documentation for the provider you are using for more
57+
# information on available options.
58+
59+
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
60+
# such as FTP and Heroku are also available. See the documentation at
61+
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
62+
# config.push.define "atlas" do |push|
63+
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
64+
# end
65+
66+
config.ssh.insert_key = true
67+
# try to set a different default user
68+
if VAGRANT_COMMAND == "ssh"
69+
config.ssh.username = 'travis'
70+
config.ssh.insert_key = true
71+
end
72+
73+
# config.ssh.username = "travis"
74+
# config.ssh.insert_key = false
75+
76+
# Enable provisioning with a shell script. Additional provisioners such as
77+
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
78+
# documentation for more information about their specific syntax and use.
79+
config.vm.provision "shell", inline: <<-SHELL
80+
useradd -m -s /bin/bash travis
81+
usermod -a -G vagrant travis
82+
echo -e "travis\ntravis\n" | sudo passwd travis
83+
[ -d /home/travis/.ssh ] || sudo mkdir -p /home/travis/.ssh
84+
cp /home/vagrant/.ssh/authorized_keys /home/travis/.ssh/
85+
sudo chown -R travis:travis /home/travis
86+
sudo chmod 600 /home/travis/.ssh/authorized_keys
87+
sudo chown travis:travis /home/travis/.ssh/authorized_keys
88+
# sudo echo "AllowUsers travis" >> /etc/ssh/sshd_config
89+
# echo 'linuxbrew ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers # emulate no sudo on travis
90+
sudo apt-get update
91+
sudo apt-get update --fix-missing -y
92+
sudo apt-get install -y gawk build-essential ruby curl git jq python-pip python-setuptools
93+
unset LD_LIBRARY_PATH PKG_CONFIG_PATH
94+
echo 'sudo su -l travis' | cat >> /home/vagrant/.bash_profile
95+
echo 'export PATH="${HOME}/.linuxbrew/bin:$PATH"' | cat >> /home/travis/.bash_profile
96+
echo 'cd ${HOME}/build/sourceryinstitute/opencoarrays' | cat >> /home/travis/.bash_profile
97+
SHELL
98+
end

developer-scripts/git-hooks/commit-msg

Lines changed: 52 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,52 @@
11
#!/bin/bash
22
#
3-
# An example hook script to check the commit log message.
3+
# A hook script to check the commit log message.
44
# Called by "git commit" with one argument, the name of the file
55
# that has the commit message. The hook should exit with non-zero
66
# status after issuing an appropriate message if it wants to stop the
77
# commit. The hook is allowed to edit the commit message file.
88
#
9-
# To enable this hook, rename this file to "commit-msg".
9+
# This hook is inteded to be used by OpenCoarrays developers to ensure
10+
# that they conform to project standards.
1011

11-
# Uncomment the below to add a Signed-off-by line to the message.
12-
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
13-
# hook is more suited to it.
14-
#
15-
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
16-
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
12+
13+
14+
set -o errexit
15+
set -o pipefail
16+
set -o nounset
17+
set -o errtrace
18+
19+
__file=commit-msg
20+
21+
err_report() {
22+
error_code=$?
23+
echo 2>&1 "Error in $__file in function $1 on line $2"
24+
exit $error_code
25+
}
26+
27+
trap 'err_report "${FUNCNAME:-.}" $LINENO' ERR
1728

1829
# error message function for writing good commit messages
30+
# shellcheck disable=SC2006,SC2035
1931
error_message () {
20-
cat <<\EOF >&2
32+
cat <<-EOF
2133
Error: bad commit message format. A copy of your commit message is in:
22-
`.git/COMMIT_EDITMSG`. Please fix it or write a new one according to the
34+
'.git/COMMIT_EDITMSG'. Please fix it or write a new one according to the
2335
guidlines below.
2436
2537
The first line of a commit message should start with a capitalized imperative
2638
verb used in a phrase to summarize the change. This first line must be less
2739
than 50 characters, followed by an additional blank line. Further detials are
2840
added after these first two lines, and may be up to 72 characters in length.
2941
30-
This is so that `--oneline` formatted `git log`s will contain human readable,
42+
This is so that '--oneline' formatted 'git log's will contain human readable,
3143
meaningful information, and the summaries on Github.com will also contain
3244
this concise summary. The 72 line limit is to ensure propper formatting on
3345
all terminals.
3446
3547
Here is an example of a good commit message:
3648
37-
```
49+
"""
3850
Redirect user to the requested page after login
3951
4052
https://github.com/sourceryinstitute/opencoarrays/Issues/29
@@ -46,11 +58,11 @@ being redirected to the login form.
4658
* Store requested path in a session variable
4759
* Redirect to the stored location after successfully logging in the user
4860
* Fixes #1
49-
```
61+
"""
5062
5163
As opposed to doing something bad like this:
5264
53-
`git commit -m "Fix login bug"`
65+
'git commit -m "Fix login bug"'
5466
5567
For more information on writting good commit messages,
5668
and keeping a clean history, please see:
@@ -65,50 +77,41 @@ EOF
6577

6678
}
6779

68-
let status=0
69-
70-
# This example catches duplicate Signed-off-by lines.
71-
72-
test "" = "$(grep '^Signed-off-by: ' "$1" |
73-
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
74-
echo >&2 "Duplicate Signed-off-by lines."
75-
let status=1
76-
}
80+
status=0
7781

7882
# Check that the first line of the commit starts with a
7983
# capitalized letter.
80-
if ! (head -n 1 $1 | grep '^[A-Z]' &>/dev/null ); then
84+
if ! (head -n 1 "$1" | grep '^[A-Z]' &>/dev/null ); then
8185
echo >&2 "First word of commit message must be a capitalized imperative verb."
8286
echo ""
83-
let status=1
87+
status=1
8488
fi
8589

8690
# Check each line for propper length
8791
ln=0
88-
cat $1 | \
89-
while read line; do
90-
let ln+=1
91-
nchars=$(wc -c <<<$line)
92-
if [[ "$ln" -eq "1" ]]; then
93-
if [[ "$nchars" -gt "51" ]]; then
94-
echo >&2 "First line of commit message too long ($nchars > 50 chars)"
95-
echo ""
96-
let status=1
97-
fi
98-
elif [[ "$ln" -eq "2" ]]; then
99-
if [[ "$nchars" -gt "1" ]] && ! grep '^#' <<<"$line" >/dev/null; then
100-
echo >&2 "Second line of commit message not blank"
101-
echo ""
102-
let status=1
103-
fi
104-
else
105-
if [[ "$nchars" -gt "72" ]]; then
106-
echo >&2 "Line $ln of commit message too long ($nchars > 72 chars)"
107-
echo ""
108-
let status=1
109-
fi
110-
fi
111-
done
92+
while read -r line; do
93+
ln+=1
94+
nchars=$(wc -c <<<"$line")
95+
if [[ "$ln" -eq "1" ]]; then
96+
if [[ "$nchars" -gt "51" ]]; then
97+
echo >&2 "First line of commit message too long ($nchars > 50 chars)"
98+
echo ""
99+
status=1
100+
fi
101+
elif [[ "$ln" -eq "2" ]]; then
102+
if [[ "$nchars" -gt "1" ]] && ! grep '^#' <<<"$line" >/dev/null; then
103+
echo >&2 "Second line of commit message not blank"
104+
echo ""
105+
status=1
106+
fi
107+
else
108+
if [[ "$nchars" -gt "72" ]]; then
109+
echo >&2 "Line $ln of commit message too long ($nchars > 72 chars)"
110+
echo ""
111+
status=1
112+
fi
113+
fi
114+
done < "$1"
112115

113116
if [[ $status = 0 ]]; then
114117
exit 0

0 commit comments

Comments
 (0)