Skip to content

Commit

Permalink
[tests] Fix breakage on Windows
Browse files Browse the repository at this point in the history
The Windows equivalent of $HOME is $LocalAppData, we need to give checks
access to that var as well or else `go` commands fail because they can't
evaluate a cache directory, which has broken the tests in the Windows
GitHub workflow.

Also be more consistent about not using trailing commas after textproto
fields, since they're unnecessary.

Change-Id: Ia3c396bd78f2d72eff18ebb2b1e1394eb878fefe
Reviewed-on: https://fuchsia-review.googlesource.com/c/shac-project/shac/+/930374
Fuchsia-Auto-Submit: Oliver Newman <[email protected]>
Reviewed-by: Ina Huh <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
  • Loading branch information
orn688 authored and CQ Bot committed Oct 12, 2023
1 parent 1f0699b commit 505bdf3
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 24 deletions.
11 changes: 8 additions & 3 deletions internal/engine/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,14 +751,19 @@ func TestRun_PassthroughEnv(t *testing.T) {
IsPath: true,
Writeable: true,
},
// Additionally give access to HOME (or LocalAppData on Windows),
// which contains the Go cache, so checks that run `go run` can use
// cached artifacts.
{
// Additionally give access to HOME, which contains the
// Go cache, so checks that run `go run` can use cached
// artifacts.
Name: "HOME",
IsPath: true,
Writeable: true,
},
{
Name: "LocalAppData",
IsPath: true,
Writeable: true,
},
},
Vars: []*Var{{Name: "VAR_PREFIX"}},
}
Expand Down
20 changes: 13 additions & 7 deletions internal/engine/testdata/fail_or_throw/shac.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Give access to $GOCACHE (and $HOME so $GOCACHE can be inferred if unset), so
# checks that run `go run` can use cached artifacts.
# Give access to $GOCACHE, as well as $HOME and $LocalAppData (for Windows) so
# $GOCACHE can be inferred if unset, so checks that run `go run` can use cached
# artifacts.
passthrough_env: [
{
name: "HOME",
is_path: true,
name: "HOME"
is_path: true
writeable: true
},
{
name: "GOCACHE",
is_path: true,
name: "LocalAppData"
is_path: true
writeable: true
},
{
name: "GOCACHE"
is_path: true
writeable: true
}
]
]
20 changes: 13 additions & 7 deletions internal/engine/testdata/print/shac.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Give access to $GOCACHE (and $HOME so $GOCACHE can be inferred if unset), so
# checks that run `go run` can use cached artifacts.
# Give access to $GOCACHE, as well as $HOME and $LocalAppData (for Windows) so
# $GOCACHE can be inferred if unset, so checks that run `go run` can use cached
# artifacts.
passthrough_env: [
{
name: "HOME",
is_path: true,
name: "HOME"
is_path: true
writeable: true
},
{
name: "GOCACHE",
is_path: true,
name: "LocalAppData"
is_path: true
writeable: true
},
{
name: "GOCACHE"
is_path: true
writeable: true
}
]
]
19 changes: 12 additions & 7 deletions shac.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,22 @@ vars: [
passthrough_env: [
{
# Provide Go commands access to the Go cache to speed up compilation.
name: "GOCACHE",
name: "GOCACHE"
is_path: true
writeable: true
},
# The Go cache directory is computed based on $HOME (or $LocalAppData) on
# Windows in the absence of $GOCACHE.
# TODO(olivernewman): Implement support for constructing pass-throughs using
# Starlark, and pass through the value returned by `go env GOCACHE` instead
# of all of $HOME/$LocalAppData.
{
# The Go cache directory is computed based on $HOME in the absence of
# $GOCACHE.
# TODO(olivernewman): Implement support for constructing pass-throughs
# using Starlark, and pass through the value returned by `go env
# GOCACHE` instead of all of $HOME.
name: "HOME",
name: "HOME"
is_path: true
writeable: true
},
{
name: "LocalAppData"
is_path: true
writeable: true
}
Expand Down

0 comments on commit 505bdf3

Please sign in to comment.