20 Commits

Author SHA1 Message Date
libo2_yewu
fa84e20b7a scripts/coverage.py: correct the coverage report path
the `path/name` directory is not exist and needs to be created first.

Signed-off-by: libo-sober <libo_sober@163.com>

Closes scylladb/scylladb#25480
2025-08-19 13:01:49 +03:00
Avi Kivity
f3eade2f62 treewide: relicense to ScyllaDB-Source-Available-1.0
Drop the AGPL license in favor of a source-available license.
See the blog post [1] for details.

[1] https://www.scylladb.com/2024/12/18/why-were-moving-to-a-source-available-license/
2024-12-18 17:45:13 +02:00
Kefu Chai
1b57ba44eb scripts/coverage.py: s/exit/sys.exit/
the former is supposed to be used in "the interactive interpreter
shell and should not be used in programs.". this function
prints out its argument, and the exit code is 1. so just
print the error message using sys.exit()

see also
https://docs.python.org/3/library/sys.html#sys.exit and
https://docs.python.org/3/library/constants.html#exit

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-12-13 10:50:00 +08:00
Kefu Chai
7600b68d5c scripts/coverage.py: do not inherit Value from argparse.Action
as Value is not an argparse.Action, and it is not passed as the argument
of the "action" parameter. neither does it implement the `__call__`
function. so just derive it from object.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-12-13 10:41:52 +08:00
Kefu Chai
9c112dacc4 scripts/coverage.py: use is not None
`is not None` is the more idiomatic Python way to check if an
expression evaluates to not None. and it is more readable.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-12-13 10:41:52 +08:00
Kefu Chai
0d15fc57d5 scripts/coverage.py: correct the formatted string in error message
the formatted string should be `basename`. `input_file` is not defined
in that context.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-12-13 10:41:52 +08:00
Kefu Chai
bc94b7bc04 scripts/coverage.py: do not use f-string when nothing to format
there is no string interpolation in this case, so drop the "f" prefix.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-12-13 10:41:52 +08:00
Kefu Chai
c3c715236d scripts/coverage.py: use raw string to avoid escaping "\"
we use "\." to escape "." in a regular expression. but "\" should
be escaped as well, CPython accepts "\." after trying to find
an escaped character of "\."  but failed, and leave "\." as it is.
but it complains:

```
/home/kefu/dev/scylladb/scripts/coverage.py:107: SyntaxWarning: invalid escape sequence '\.'
  input_file_re_str = f"(.+)\.profraw(\.{__DISTINCT_ID_RE})?"
```

in this change, we use raw string to avoid escaping "\" in
the regular expression.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-12-13 10:41:52 +08:00
Botond Dénes
ed025890e5 scripts/coverage.py: --run: swallow KeyboardInterrupt
It is quite common to stop a tested scylla process with ^C, which will
raise KeyboardInterrupt from subprocess.run(). Catch and swallow this
exception, allowing the post-processing to continue.
The interrupted process has to handle the interrupt correctly too --
flush the coverage data even on premature exit -- but this is for
another patch.

Closes #14815
2023-07-25 12:29:22 +03:00
Avi Kivity
fcb8d040e8 treewide: use Software Package Data Exchange (SPDX) license identifiers
Instead of lengthy blurbs, switch to single-line, machine-readable
standardized (https://spdx.dev) license identifiers. The Linux kernel
switched long ago, so there is strong precedent.

Three cases are handled: AGPL-only, Apache-only, and dual licensed.
For the latter case, I chose (AGPL-3.0-or-later and Apache-2.0),
reasoning that our changes are extensive enough to apply our license.

The changes we applied mechanically with a script, except to
licenses/README.md.

Closes #9937
2022-01-18 12:15:18 +01:00
Avi Kivity
a55b434a2b treewide: extent copyright statements to present day 2021-06-06 19:18:49 +03:00
Botond Dénes
438391b4cc scripts/coverage.py: check that --path is a directory
To detect a bad --path that would fail coverage generation early.
2021-06-06 09:21:23 +03:00
Botond Dénes
ca91fd0e34 scripts/coverage.py: update main()'s docstring with new --run modifiers
And fix a typo while there.
2021-06-06 09:21:23 +03:00
Botond Dénes
2ba3fc2e11 scripts/coverage.py: add --distinct-id parameter
Yet another modifier for `--run`, allowing running the same executable
multiple times and then generating a coverage report across all runs.
This will also be used by test.py for those test suites (cql test) which
run the same executable multiple times, with different inputs.
2021-06-06 09:21:23 +03:00
Botond Dénes
b1f46b3693 scripts/coverage.py: add --executable parameter
Another modifier for `--run`, allowing to override the test executable
path. This is useful when the real test is ran through a run-script,
like in the case of cql-pytest.
2021-06-06 09:21:23 +03:00
Botond Dénes
cd17932b96 scripts/coverage.py: document intended uses-cases 2021-05-21 11:50:39 +03:00
Botond Dénes
4647472fee scripts/coverage.py: add --verbose parameter 2021-05-21 11:50:39 +03:00
Botond Dénes
2d7fe702e1 scripts/coverage.py: add capability of running a test directly
Through `coverage.py`. This saves the user from all the required env
setup required for `coverage.py` to successfully generate the report
afterwards. Instead all of this is taken care automatically, by just
running:

    ./scripts/coverage.py --run ./build/coverage/.../mytest arg1 ...  argN

`coverage.py` takes care of running the test and generating a coverage
report from it.

As a side effect, also fix `main()` ignoring its `argv` parameter.
2021-05-21 11:50:39 +03:00
Botond Dénes
64c4557ba8 scripts/coverage.py: allow specifying the input files to generate the report from
Currently `coverage.py` includes all raw profiling data found at PATH
automatically. This patch gives an option to override this, instead
including only the given input files in the report.
2021-05-21 11:50:39 +03:00
Botond Dénes
bc3a424b0e scripts: introduce coverage.py
This script finds all the profiling data generated by tests at the
specified path, it merges them and generates a html report combining all
their results.
It can be used both as a standalone python script, or imported and
invoked from python directly.
2021-05-07 15:54:49 +03:00