Rewrite testfiles to have multiversion testing locally#165
Rewrite testfiles to have multiversion testing locally#165furtib wants to merge 6 commits intoEricsson:mainfrom
Conversation
2c48880 to
cb78eed
Compare
There was a problem hiding this comment.
Very good initiative @furtib!
But, sorry, test runner is really bad idea.
To move forward, may I suggest splitting this patch to 2:
- This one to actually address multiversion testing locally
- New one to re-implement tests that they clean after themselves without external cleaners
If I may, the following might help for the second part:
class TemporaryDir:
"""
Safely creates and destroys temporary folder
"""
def __init__(self):
self._temp_dir = None
def __enter__(self):
self._temp_dir = tempfile.mkdtemp()
logging.debug("Created %s", self._temp_dir)
return self._temp_dir
def __exit__(self, tipe, value, traceback):
shutil.rmtree(self._temp_dir)
logging.debug("Removed %s", self._temp_dir)
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| git clone --recurse https://github.com/jbeder/yaml-cpp.git test-proj |
There was a problem hiding this comment.
I was wondering why do we need --recurse?
Does this repo have submodules?
There was a problem hiding this comment.
Just stayed in from the original script.
test/foss/yaml-cpp/init.sh
Outdated
| git reset --hard | ||
| git clean -fd |
There was a problem hiding this comment.
I guess rm -rf test-proj is much safer.
Actually, we must always clean up after test, but that's different discussion
test/test_foss.sh
Outdated
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| python3 test_runner.py foss @a |
test/test_runner.py
Outdated
| This file runs tests. | ||
| For unittest pass `unit` as parameter | ||
| For FOSS tests pass `foss` as parameter | ||
| For verbosity use `-vvv` | ||
| To clean up FOSS test artifacts use `--clean` | ||
| To run the specified tests on all supported Bazel versions use `--all` |
There was a problem hiding this comment.
I'm strictly against any test runners and wrappers around wrappers :)
If we cannot run python unittests via standard python -m unittest, if we need pre-initialization, if tests do not clean themselves, if we need special cleaner, then something is definitely wrong.
9a28309 to
e640e3a
Compare
e640e3a to
c65bfb6
Compare
|
I reworked it a bit, removed anything that is not strictly necessary for automated testing of multiple Bazel versions. I may be short-sighted, but I don't know how I could do this without the help of a wrapper around |
nettle
left a comment
There was a problem hiding this comment.
To me this patch is quite controversial.
Here are my reasons:
- I think it does not help much in running tests locally
- It does aim only at bazel multiversion, but not other tools (at least CodeChecker)
- It implies we always have bazelisk instead of bazel which not the case
- It makes tests depend on .github which is really not good
- It adds more unnecessary layering which hides testing functionality
| @@ -1,2 +1,17 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
I think the following shebang is recommended:
#!/usr/bin/env bash
| @@ -1,2 +1,17 @@ | |||
| #!/bin/bash | |||
| python3 -m unittest discover unit $@ | |||
There was a problem hiding this comment.
If we introduce test/test_foss.sh then this file should be test/test_unit.sh
| # Copyright 2023 Ericsson AB | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. |
There was a problem hiding this comment.
I guess this is not much needed for "convenience" scripts
There was a problem hiding this comment.
We have the license in empts __init__.py files too.
Better safe than sorry.
| This script replaces the content of the .bazelversion file | ||
| from .github/bazel_version.json and runs the equivalent of | ||
| python3 -m unittest discover @a | ||
| For unittest pass `unit` as parameter | ||
| For FOSS tests pass `foss` as parameter #TODO: Add cleanup between FOSS runs | ||
| For verbosity use `-vvv` |
There was a problem hiding this comment.
To be honest I dont understand the meaning of this so far...
Looks like something which depends on bazelisk. Am I right?
There was a problem hiding this comment.
You are right, this does depend on bazelisk. My goal was to make this script as simple as it can get. And to be honest, I didn't think testing multiple Bazel versions without bazelisk was even possible.
|
Now that we seem to be on board with Mise (#132), is this patch still relevant? |
Probably not... |
|
Closing this PR since this issue has been addressed in #132. |
Why:
We have no automated way to run tests for multiple Bazel versions.
What:
test_all_bazel_version.pyto change the.bazelversionfile's contents between running the tests.Addresses:
none