Permutation tests using arbitrary permutation distributions