Skip to content

try to avoid recording tests#354

Merged
apotterri merged 6 commits into
masterfrom
no-test-cases_20240715
Jul 26, 2024
Merged

try to avoid recording tests#354
apotterri merged 6 commits into
masterfrom
no-test-cases_20240715

Conversation

@apotterri

Copy link
Copy Markdown
Contributor

When creating the default config, ignore directories with names that
match the regex .test.. This should avoid instrumenting the majority
of test functions. For those that do still get instrumented, have the
test framework integration disable the wrapt wrapped on it, thereby
disabling recording.

Also, some issues I found with the way the f{set,get,del} functions of properties were handled. And, adds an environment variable to disable instrumenting properties altogether.

Fixes #351

In addition to the path of config file, show the packages property, too.
Add APPMAP_INSTRUMENT_PROPERTIES to control whether properties should be
instrumented.
@apotterri apotterri force-pushed the no-test-cases_20240715 branch from 74a63b8 to e1af996 Compare July 23, 2024 09:03
@apotterri apotterri marked this pull request as ready for review July 23, 2024 09:12
@apotterri apotterri force-pushed the no-test-cases_20240715 branch from e1af996 to b133145 Compare July 23, 2024 09:17
@dustinbyrne dustinbyrne requested a review from dividedmind July 23, 2024 13:05
Comment thread _appmap/importer.py Outdated
if new_fn != fn:
new_fn = wrapt.FunctionWrapper(fn, new_fn)
setattr(new_fn, "_appmap_wrapped", True)
# Set _appmap_wrapped on the FunctionWrapper, not on the wrapped function

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_appmap_instrumented

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks.

object.__setattr__(self, '_self_binding', binding)
object.__setattr__(self, '_self_parent', parent)
object.__setattr__(self, '_bfws', list())
object.__setattr__(self, "_appmap_instrumented", False)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how I feel about modifying a vendored lib. I'm worried it'll be too easy to miss it when we update or if we ever decide to switch to non-vendored.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the first change I've had to make to wrapt, so it's already the case that we have to merge from upstream, rather than just overwriting. Those other changes will also keep us from switching to non-vendored....

Base the decision to instrument a property on the property name, rather
than trying to use the name of the f{get,set,del} functions. This aligns
them with the rest of the class's members, e.g. for exclusion.

Also, ensure that those functions only get instrumented once.
When creating the default config, ignore directories with names that
match the regex .*test.*. This should avoid instrumenting the majority
of test functions. For those that do still get instrumented, have the
test framework integration disable the wrapt wrapped on it, thereby
disabling recording.
Add ruff to dev dependencies, along with an example config. At some
point in the future, we may want to switch to using it, rather than
pylint.
The latest update to incremental (which twisted depends on), appears to
be broken. Pin to the previous version.
@apotterri apotterri force-pushed the no-test-cases_20240715 branch from c0197b6 to 7538fa7 Compare July 26, 2024 17:45
@apotterri apotterri merged commit 171625a into master Jul 26, 2024
@apotterri apotterri deleted the no-test-cases_20240715 branch July 26, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests are not included in AppMaps

2 participants