Sergey Raevskiy <sergey.raevskiy_at_visualsvn.com> writes:
> +static svn_error_t *
> +pre_commit_hook_lock_token_without_path(const svn_test_opts_t *opts,
> + apr_pool_t *pool)
> +{
> + svn_repos_t *repos;
> + svn_fs_access_t *access;
> + svn_fs_txn_t *txn;
> + svn_fs_root_t *root;
> + const char *conflict;
> + svn_revnum_t new_rev;
> +
> + /* Create test repository. */
> + SVN_ERR(svn_test__create_repos(&repos, "pre_commit_hook_tokens_test",
> + opts, pool));
> +
> + /* Set an empty pre-commit hook. */
> + SVN_ERR(svn_io_file_create(svn_repos_pre_commit_hook(repos, pool),
> + "exit 0", pool));
> + SVN_ERR(svn_io_set_file_executable(svn_repos_pre_commit_hook(repos, pool),
> + TRUE, FALSE, pool));
How is that going to work? "exit 0" is not a valid hook script. It
might work with an additional "/bin/sh" but that is not portable.
> +
> + /* Set some access context using svn_fs_access_add_lock_token(). */
> + SVN_ERR(svn_fs_create_access(&access, "jrandom", pool));
> + SVN_ERR(svn_fs_access_add_lock_token(access, "opaquelocktoken:abc"));
> + SVN_ERR(svn_fs_set_access(svn_repos_fs(repos), access));
> +
> + /* Try to commit a new revision. */
> + SVN_ERR(svn_repos_fs_begin_txn_for_commit2(&txn, repos, 0,
> + apr_hash_make(pool), pool));
> + SVN_ERR(svn_fs_txn_root(&root, txn, pool));
> + SVN_ERR(svn_fs_make_dir(root, "/whatever", pool));
> + SVN_ERR(svn_fs_commit_txn(&conflict, &new_rev, txn, pool));
Ah! The fs layer does not run any hooks, you need to use the repos
layer's svn_repos_fs_commit_txn to run hooks. But that will not work
because the hook is not portable.
> +
> + SVN_TEST_STRING_ASSERT(conflict, NULL);
> + SVN_TEST_ASSERT(new_rev == 1);
> +
> + return SVN_NO_ERROR;
> +}
> +
> /* The test table. */
>
> static int max_threads = 4;
> @@ -3615,6 +3654,8 @@ static struct svn_test_descriptor_t test_funcs[] =
> "test svn_repos__config_pool_*"),
> SVN_TEST_OPTS_PASS(test_repos_fs_type,
> "test test_repos_fs_type"),
> + SVN_TEST_OPTS_PASS(pre_commit_hook_lock_token_without_path,
> + "test legacy access context api"),
> SVN_TEST_NULL
> };
>
>
--
Philip Martin | Subversion Committer
WANdisco // *Non-Stop Data*
Received on 2015-02-06 11:10:52 CET