>
> +def ensure_dependencies():
> +  """Install the dependencies we need for running the tests.
> +
> +  NOTE: this function des not handle the case where the Python
> +        version has changed. In theory, we could automagically
> +        upgrade the venv in that case. In practice, we won't.
> +  """
> +
> +  global dependencies_ensured
> +  if dependencies_ensured:
> +    return
> +
> +  package_path = os.path.join(venv_dir, "lib",
> +                              "python%d.%d" % sys.version_info[:2],
> +                              "site-packages")
> +  package_path = os.path.abspath(package_path)
> +  if package_path in sys.path:
> +    dependencies_ensured = True
> +    return
> +
> +  try:
> +    # Create the virtual environment
> +    if not os.path.isdir(venv_dir):
> +      if os.path.exists(venv_dir):
> +        safe_rmtree(venv_dir)
> +      venv.create(venv_dir, with_pip=True)
> +
> +    # Install any (new) dependencies
> +    pip = os.path.join(venv_dir, venv_bin, "pip"+_exe)
> +    pip_options = ("--disable-pip-version-check", "--require-virtualenv")
>
> * +    subprocess.run([pip, *pip_options, "install", *SVN_TESTS_REQUIRE],
> +                   check=True)*
> +
> +    sys.path.append(package_path)
> +    dependencies_ensured = True
> +    return package_path
> +  except Exception as ex:
> +    print("WARNING: Could not install test dependencies,"
> +          " some tests will be skipped", file=sys.stderr)
> +    print(ex, file=sys.stderr)


It is generally a great idea to verify the xml schema of the --xml output.

However, I'd not agree with the part where a pip library is installed
during the execution of the test script. Let me explain my point...

Imagine I am running the test suite in a clean environment and I don't want
to download anything from the internet. I download the library source code
distributions directly from tarballs, and verify the hash to ensure it's
the correct one. In the other words, doing anything to avoid unwanted files
appearing on my computer. But when I run the tests, I'm implicitly getting
this pip package of the latest version on my machine. Also, if I had the
internet disabled, the tests would have been skipped.. I don't think this
would be the best choice for such users who want their scripts to run
without external things affecting their configuration.

Also, we are avoiding to build our dependencies manually in the build
scripts. All the build systems I've dug down into (autoconf, cmake,
gen-win) are searching for the dependencies on either the system or in a
specific location. (except for the tools\dev\unix-build\Makefile.svn script
which is actually made to build all the dependencies from blank.

Instead of downloading the required library directly from the tests, I'd
suggest adding an option whether we want to verify schemas or not. Then we
can say that if so, you should install the library using your own way. Also
we can not only warn if the dependency could not be located, but fail it
straight away to avoid implicit changes of behaviour.

Alternatively, if the license allows so and the library is like just a few
files and it's not that hard to maintain the versions, you just could put
its source code directly into the repo and assume that we always have it in
the source tree. As far as I understand, this is currently used for ezt
python generator (which is actually made by gstein), lz4, utf8proc, but I
think these libraries can also be installed on the system.

Thoughts?

PS: maybe it makes sense to add a possibility to run the whole test suite
in venv? I'm actually aware of how it works, sorry if I'm wrong...

-- 
Timofei Zhakov

Reply via email to