dap: properly map source paths to client side paths
Properly map the source paths from the metadata in the solve to the client side paths. The source path returns is relative to the context that gets uploaded which is usually a subdirectory. The original code noticed this when mapping the paths but made the invalid assumption that the dockerfile would always be in the context path so it combined the dockerfile name with the context path. It is possible for the dockerfile to be in a subdirectory of the context. In which case, we computed the paths incorrectly. This modifies DAP to instead use the `DockerfileMappingDst` and `DockerfileMappingSrc` which are special included variables to the inputs that get filled in during the build for the purpose of mapping the source path to the client side path. Tests have also been added for this functionality to ensure it doesn't break again. This should work with both absolute and relative paths although absolute paths should probably be preferred for usage just because they're less likely to result in weird things happening. The sources are also normalized to always convert the source filenames to absolute paths and DAP itself will accept relative paths but will only ever communicate in absolute paths. When you set a breakpoint, it will convert it to an absolute path and reference it in that way rather than a relative path. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
+2
-2
@@ -187,12 +187,12 @@ func TestBreakpointMapIntersectVerified(t *testing.T) {
|
||||
src := &pb.Source{
|
||||
Locations: srcLocs,
|
||||
Infos: []*pb.SourceInfo{
|
||||
{Filename: filename},
|
||||
{Filename: fpath},
|
||||
},
|
||||
}
|
||||
|
||||
ctx := newBreakpointTestContext(t)
|
||||
digests := bm.Intersect(ctx, src, ws)
|
||||
digests := bm.Intersect(ctx, src)
|
||||
wantMatches := 0
|
||||
for _, bc := range breakpointCases {
|
||||
if bc.expectVerified {
|
||||
|
||||
Reference in New Issue
Block a user