Merge lp:~elopio/snappy/goarm_tests into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Leo Arias
Status: Merged
Approved by: Leo Arias
Approved revision: 649
Merged at revision: 647
Proposed branch: lp:~elopio/snappy/goarm_tests
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Prerequisite: lp:~fgimenez/snappy/fix-fake-env
Diff against target: 69 lines (+33/-10)
2 files modified
_integration-tests/testutils/build/build.go (+9/-2)
_integration-tests/testutils/build/build_test.go (+24/-8)
To merge this branch: bzr merge lp:~elopio/snappy/goarm_tests
Reviewer Review Type Date Requested Status
Federico Gimenez (community) Approve
Snappy Developers Pending
Review via email: mp+269774@code.launchpad.net

This proposal supersedes a proposal from 2015-08-27.

Commit message

Fixed the arm compilation in integration tests.

To post a comment you must log in.
Revision history for this message
Federico Gimenez (fgimenez) wrote : Posted in a previous version of this proposal

Looks very good :)

The tests are not passing for me, it seems that maybe we need [1] to be applied before this.

Also, with that in place I get an error about the set of CGO_ENABLED to 1 being executed two times, maybe 1 is the default value for it, we could set all the environment variables to known values before the assertions.

Thanks!

[1] https://code.launchpad.net/~fgimenez/snappy/setenv-closure-redefinition/+merge/269717

review: Needs Fixing
Revision history for this message
Federico Gimenez (fgimenez) wrote : Posted in a previous version of this proposal

There was a problem with the fake environment variables, the prerequisite should be [1]

Thanks

[1] https://code.launchpad.net/~fgimenez/snappy/fix-fake-env/+merge/269741

Revision history for this message
Federico Gimenez (fgimenez) wrote : Posted in a previous version of this proposal

For setting the environment variables with the changes in the prerequisite now we can access the s.environ map directly before the Assets call:

s.environ["CC"] = os.Getenv("CC")

Also a minor inline comment, thanks!

lp:~elopio/snappy/goarm_tests updated
649. By Leo Arias

Set the variables to a know value different to the one we need.

Revision history for this message
Leo Arias (elopio) wrote :

Federico, I pushed a new revision. I prefer to keep the scenarios out of the test, but if you feel strongly about it, I can just put them in the for as you suggested. No big deal for me.

Revision history for this message
Federico Gimenez (fgimenez) wrote :

No problem, that's fine.

I'm getting one error on the tests, the one related to the setting of CGO_ENABLED being called two times, one before the compilation and other after it. It seems that the value that we are setting here is already the default.

Executed in wily, go1.5, don't you get this error?

Revision history for this message
Leo Arias (elopio) wrote :

I don't get that error.
But I think that with s.environ[t.envVar] = "original" + t.envVar, GGO_ENABLED will return to a value that's not 1, so it shouldn't be called twice. Can it be called somewhere else in between?

Revision history for this message
Federico Gimenez (fgimenez) wrote :

Ok, it's working now, thanks! :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '_integration-tests/testutils/build/build.go'
2--- _integration-tests/testutils/build/build.go 2015-08-10 10:01:18 +0000
3+++ _integration-tests/testutils/build/build.go 2015-09-01 16:11:25 +0000
4@@ -80,8 +80,15 @@
5 defer osSetenv("GOARCH", osGetenv("GOARCH"))
6 osSetenv("GOARCH", arch)
7 if arch == "arm" {
8- defer osSetenv("GOARM", osGetenv("GOARM"))
9- osSetenv("GOARM", defaultGoArm)
10+ envs := map[string]string{
11+ "GOARM": defaultGoArm,
12+ "CGO_ENABLED": "1",
13+ "CC": "arm-linux-gnueabihf-gcc",
14+ }
15+ for env, value := range envs {
16+ defer osSetenv(env, osGetenv(env))
17+ osSetenv(env, value)
18+ }
19 }
20 }
21 execCommand(strings.Fields(cmd)...)
22
23=== modified file '_integration-tests/testutils/build/build_test.go'
24--- _integration-tests/testutils/build/build_test.go 2015-09-01 16:11:25 +0000
25+++ _integration-tests/testutils/build/build_test.go 2015-09-01 16:11:25 +0000
26@@ -161,19 +161,35 @@
27 "GOARCH "+os.Getenv("GOARCH"), setenvGOARCHFinalCall))
28 }
29
30+var armEnvironmentTests = []struct {
31+ envVar string
32+ value string
33+}{
34+ {"GOARM", defaultGoArm},
35+ {"CGO_ENABLED", "1"},
36+ {"CC", "arm-linux-gnueabihf-gcc"},
37+}
38+
39 func (s *BuildSuite) TestAssetsSetsEnvironmentForArm(c *check.C) {
40 arch := "arm"
41+ for _, t := range armEnvironmentTests {
42+ s.environ[t.envVar] = "original" + t.envVar
43+ }
44 Assets(s.useSnappyFromBranch, arch)
45
46- setenvGOARMFirstCall := s.osSetenvCalls["GOARM "+defaultGoArm]
47- setenvGOARMFinalCall := s.osSetenvCalls["GOARM "+os.Getenv("GOARM")]
48+ for _, t := range armEnvironmentTests {
49+ firstCall := fmt.Sprintf("%s %s", t.envVar, t.value)
50+ setenvFirstCall := s.osSetenvCalls[firstCall]
51+ finalCall := fmt.Sprintf("%s %s", t.envVar, "original"+t.envVar)
52+ setenvFinalCall := s.osSetenvCalls[finalCall]
53
54- c.Assert(setenvGOARMFirstCall, check.Equals, 1,
55- check.Commentf("Expected 1 call to os.Setenv with %s, got %d",
56- "GOARM "+defaultGoArm, setenvGOARMFirstCall))
57- c.Assert(setenvGOARMFinalCall, check.Equals, 1,
58- check.Commentf("Expected 1 call to os.Setenv with %s, got %d",
59- "GOARM "+os.Getenv("GOARCH"), setenvGOARMFinalCall))
60+ c.Assert(setenvFirstCall, check.Equals, 1,
61+ check.Commentf("Expected 1 call to os.Setenv with %s, got %d",
62+ firstCall, setenvFirstCall))
63+ c.Assert(setenvFinalCall, check.Equals, 1,
64+ check.Commentf("Expected 1 call to os.Setenv with %s, got %d",
65+ finalCall, setenvFinalCall))
66+ }
67 }
68
69 func (s *BuildSuite) TestAssetsDoesNotSetEnvironmentForEmptyArch(c *check.C) {

Subscribers

People subscribed via source and target branches