Skip to content

Commit

Permalink
trace: update gen.bash for oldtrace and make it work seamlessly
Browse files Browse the repository at this point in the history
Currently gen.bash doesn't work out-of-the-box because it doesn't
exactly replace contents in the trace directory in some cases. It also
may end up mutating the flight recorder files, which isn't great.

This change adds a special case for the flight recorder files, adds
support for oldtrace (which will be imported shortly), and also switches
to using rsync, which is more robust than cp for the initial copy (and
should hopefully capture file deletions correctly as well).

Change-Id: I3a808387a25c787a1edb70fcff1c95fb5649baeb
Reviewed-on: https://go-review.googlesource.com/c/exp/+/571615
Auto-Submit: Michael Knyszek <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Michael Pratt <[email protected]>
  • Loading branch information
mknyszek authored and gopherbot committed Mar 14, 2024
1 parent 814bf88 commit 35ce08e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion trace/gen.bash
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SRC=$GODIR/src/internal/trace/v2
DST=$(dirname $0)

# Copy.
cp -r $SRC/* $DST
rsync -av --delete $SRC/ $DST
rm $DST/mkexp.bash

# Remove the trace_test.go file and the testprogs it invokes.
Expand All @@ -46,6 +46,13 @@ rm $DST/mkexp.bash
rm $DST/trace_test.go
rm -r $DST/testdata/testprog

# Remove the oldtrace testdata to avoid checking in new binary files.
# Remove oldtrace_test.go and internal/oldtrace/parser_test.go because
# they fail without this data.
rm -r $DST/internal/oldtrace/testdata
rm $DST/oldtrace_test.go
rm $DST/internal/oldtrace/parser_test.go

# Remove mktests.go because its a //go:build ignore file, so it would
# complicate the logic below. This codebase isn't the source of truth
# anyway.
Expand Down Expand Up @@ -76,3 +83,6 @@ find $DST -name '*.go' | xargs -- sed -i '/LICENSE file./a \

# Format the files.
find $DST -name '*.go' | xargs -- gofmt -w -s

# Restore known files.
git checkout gen.bash flightrecorder.go flightrecorder_test.go

0 comments on commit 35ce08e

Please sign in to comment.