Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
fix: use static path in function path
Browse files Browse the repository at this point in the history
When there is only one version of a file available, we should use the
static path format. This was already the case in the classmap but not
in the event section. I added validation in tests to prevent
regressions.
  • Loading branch information
Laurent Christophe authored and dustinbyrne committed Jul 28, 2023
1 parent e876f95 commit 84e5fbb
Show file tree
Hide file tree
Showing 25 changed files with 78 additions and 29 deletions.
58 changes: 30 additions & 28 deletions components/trace/appmap/codebase/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -120,40 +120,42 @@ export const lookupClosureLocation = (
const { url, hash, position } = location;
if (codebase.has(url)) {
const { shallow, versions } = codebase.get(url);
if (hash === null) {
if (/* c8 ignore start */ versions.size === 0) {
throw new InternalAppmapError("unexpected source without version");
} /* c8 ignore stop */ else if (versions.size === 1) {
const {
value: { source },
} = versions.values().next();
return completeClosure(
source,
toStaticSpecifier(url, base),
shallow,
position,
);
} else {
logWarning(
"Ignoring closure at %j because its source has multiple versions",
location,
);
return null;
}
} else if (versions.has(hash)) {
const { source, version } = versions.get(hash);
if (/* c8 ignore start */ versions.size === 0) {
throw new InternalAppmapError("unexpected source without version");
} /* c8 ignore stop */ else if (versions.size === 1) {
const {
value: { source },
} = versions.values().next();
return completeClosure(
source,
toDynamicSpecifier(url, base, version),
toStaticSpecifier(url, base),
shallow,
position,
);
} else {
logWarning(
"Ignoring closure at %j because of source content mismatch",
location,
);
return null;
if (hash === null) {
logWarning(
"Ignoring closure at %j because its source has multiple versions",
location,
);
return null;
} else {
if (versions.has(hash)) {
const { source, version } = versions.get(hash);
return completeClosure(
source,
toDynamicSpecifier(url, base, version),
shallow,
position,
);
} else {
logWarning(
"Ignoring closure at %j because of source content mismatch",
location,
);
return null;
}
}
}
} else {
logWarningWhen(
Expand Down
2 changes: 2 additions & 0 deletions test/cases/apply-async/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/apply-generator/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/apply-mismatch/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/apply-pattern/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/apply-rest/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/apply-source/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/classmap/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/default-parameter/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/env-var/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/eval/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/generator-method/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/html/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/http/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/jest-json/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/jest-transformer-preset/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/jest-transformer/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/jest/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/metadata/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/mocha/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/npx/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/query/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: true
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/to-string/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
2 changes: 2 additions & 0 deletions test/cases/ts-node-esm/appmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ hooks:
mysql: false
pg: false
sqlite3: false
validate:
appmap: true
3 changes: 2 additions & 1 deletion test/cases/version/appmap.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{}
validate:
appmap: true

0 comments on commit 84e5fbb

Please sign in to comment.