Skip to content

Commit 4a71ddd

Browse files
authored
Merge pull request #15355 from github/mbg/go/increase-test-robustness
Go: Improve robustness of integration tests
2 parents 2d71294 + 783f006 commit 4a71ddd

File tree

98 files changed

+249
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+249
-47
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
#select
2+
| src/test.go:0:0:0:0 | src/test.go |
3+
| src/todel.go:0:0:0:0 | src/todel.go |
14
htmlFiles
25
extractionErrors
36
| Extraction failed in test.go with error \tother declaration of test | 2 |
47
| Extraction failed in todel.go with error test redeclared in this block | 2 |
5-
#select
6-
| test.go:0:0:0:0 | test.go |
7-
| todel.go:0:0:0:0 | todel.go |
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45
from diagnostics_test_utils import *
56

6-
run_codeql_database_create([], lang="go")
7+
# Set up a GOPATH relative to this test's root directory;
8+
# we set os.environ instead of using extra_env because we
9+
# need it to be set for the call to "go clean -modcache" later
10+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
11+
os.environ['GOPATH'] = goPath
12+
13+
run_codeql_database_create([], lang="go", source="src")
714

815
check_diagnostics()
16+
17+
# Clean up the temporary GOPATH to prevent Bazel failures next
18+
# time the tests are run; see https://github.com/golang/go/issues/27161
19+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
#select
2+
| src/test.go:0:0:0:0 | src/test.go |
3+
| src/todel.go:0:0:0:0 | src/todel.go |
14
htmlFiles
25
extractionErrors
36
| Extraction failed in test.go with error \tother declaration of test | 2 |
47
| Extraction failed in todel.go with error test redeclared in this block | 2 |
5-
#select
6-
| test.go:0:0:0:0 | test.go |
7-
| todel.go:0:0:0:0 | todel.go |
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45
from diagnostics_test_utils import *
56

6-
run_codeql_database_create([], lang="go")
7+
# Set up a GOPATH relative to this test's root directory;
8+
# we set os.environ instead of using extra_env because we
9+
# need it to be set for the call to "go clean -modcache" later
10+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
11+
os.environ['GOPATH'] = goPath
12+
13+
run_codeql_database_create([], lang="go", source="src")
714

815
check_diagnostics()
16+
17+
# Clean up the temporary GOPATH to prevent Bazel failures next
18+
# time the tests are run; see https://github.com/golang/go/issues/27161
19+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45
from diagnostics_test_utils import *
56

7+
# Set up a GOPATH relative to this test's root directory;
8+
# we set os.environ instead of using extra_env because we
9+
# need it to be set for the call to "go clean -modcache" later
10+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
11+
os.environ['GOPATH'] = goPath
612
os.environ['LGTM_INDEX_IMPORT_PATH'] = "test"
713
run_codeql_database_create([], lang="go", source="work", db=None)
814

915
check_diagnostics()
16+
17+
# Clean up the temporary GOPATH to prevent Bazel failures next
18+
# time the tests are run; see https://github.com/golang/go/issues/27161
19+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45
from diagnostics_test_utils import *
56

7+
# Set up a GOPATH relative to this test's root directory;
8+
# we set os.environ instead of using extra_env because we
9+
# need it to be set for the call to "go clean -modcache" later
10+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
11+
os.environ['GOPATH'] = goPath
612
os.environ['LGTM_INDEX_IMPORT_PATH'] = "test"
713
run_codeql_database_create([], lang="go", source="work", db=None, runFunction=runUnsuccessfully)
814

915
check_diagnostics()
16+
17+
# Clean up the temporary GOPATH to prevent Bazel failures next
18+
# time the tests are run; see https://github.com/golang/go/issues/27161
19+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45
from diagnostics_test_utils import *
56

7+
# Set up a GOPATH relative to this test's root directory;
8+
# we set os.environ instead of using extra_env because we
9+
# need it to be set for the call to "go clean -modcache" later
10+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
11+
os.environ['GOPATH'] = goPath
612
os.environ['LGTM_INDEX_IMPORT_PATH'] = "test"
713
run_codeql_database_create([], lang="go", source="work", db=None, runFunction=runUnsuccessfully)
814

915
check_diagnostics()
16+
17+
# Clean up the temporary GOPATH to prevent Bazel failures next
18+
# time the tests are run; see https://github.com/golang/go/issues/27161
19+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45
from diagnostics_test_utils import *
56

7+
# Set up a GOPATH relative to this test's root directory;
8+
# we set os.environ instead of using extra_env because we
9+
# need it to be set for the call to "go clean -modcache" later
10+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
11+
os.environ['GOPATH'] = goPath
612
os.environ['LGTM_INDEX_IMPORT_PATH'] = "test"
713
run_codeql_database_create([], lang="go", source="work", db=None, runFunction=runUnsuccessfully)
814

915
check_diagnostics()
16+
17+
# Clean up the temporary GOPATH to prevent Bazel failures next
18+
# time the tests are run; see https://github.com/golang/go/issues/27161
19+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45
from diagnostics_test_utils import *
56

7+
# Set up a GOPATH relative to this test's root directory;
8+
# we set os.environ instead of using extra_env because we
9+
# need it to be set for the call to "go clean -modcache" later
10+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
11+
os.environ['GOPATH'] = goPath
612
os.environ['LGTM_INDEX_IMPORT_PATH'] = "test"
713
run_codeql_database_create([], lang="go", source="work", db=None)
814

915
check_diagnostics()
16+
17+
# Clean up the temporary GOPATH to prevent Bazel failures next
18+
# time the tests are run; see https://github.com/golang/go/issues/27161
19+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45
from diagnostics_test_utils import *
56

7+
# Set up a GOPATH relative to this test's root directory;
8+
# we set os.environ instead of using extra_env because we
9+
# need it to be set for the call to "go clean -modcache" later
10+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
11+
os.environ['GOPATH'] = goPath
612
os.environ['LGTM_INDEX_IMPORT_PATH'] = "test"
713
run_codeql_database_create([], lang="go", source="work", db=None)
814

915
check_diagnostics()
16+
17+
# Clean up the temporary GOPATH to prevent Bazel failures next
18+
# time the tests are run; see https://github.com/golang/go/issues/27161
19+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45
from diagnostics_test_utils import *
56

7+
# Set up a GOPATH relative to this test's root directory;
8+
# we set os.environ instead of using extra_env because we
9+
# need it to be set for the call to "go clean -modcache" later
10+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
11+
os.environ['GOPATH'] = goPath
612
os.environ['GITHUB_REPOSITORY'] = "a/b"
713
run_codeql_database_create([], lang="go", source="work", db=None, runFunction=runUnsuccessfully)
814

915
check_diagnostics()
16+
17+
# Clean up the temporary GOPATH to prevent Bazel failures next
18+
# time the tests are run; see https://github.com/golang/go/issues/27161
19+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
#select
2+
| src/test.go:0:0:0:0 | src/test.go |
13
htmlFiles
24
extractionErrors
3-
#select
4-
| test.go:0:0:0:0 | test.go |
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45

5-
run_codeql_database_create([], lang="go")
6+
# Set up a GOPATH relative to this test's root directory;
7+
# we set os.environ instead of using extra_env because we
8+
# need it to be set for the call to "go clean -modcache" later
9+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
10+
os.environ['GOPATH'] = goPath
11+
run_codeql_database_create([], lang="go", source="src")
12+
13+
# Clean up the temporary GOPATH to prevent Bazel failures next
14+
# time the tests are run; see https://github.com/golang/go/issues/27161
15+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
#select
2+
| src/test.go:0:0:0:0 | src/test.go |
13
htmlFiles
24
extractionErrors
3-
#select
4-
| test.go:0:0:0:0 | test.go |
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45

5-
run_codeql_database_create([], lang="go")
6+
# Set up a GOPATH relative to this test's root directory;
7+
# we set os.environ instead of using extra_env because we
8+
# need it to be set for the call to "go clean -modcache" later
9+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
10+
os.environ['GOPATH'] = goPath
11+
run_codeql_database_create([], lang="go", source="src")
12+
13+
# Clean up the temporary GOPATH to prevent Bazel failures next
14+
# time the tests are run; see https://github.com/golang/go/issues/27161
15+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
#select
2+
| src/test.go:0:0:0:0 | src/test.go |
13
htmlFiles
24
extractionErrors
3-
#select
4-
| test.go:0:0:0:0 | test.go |
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45

5-
run_codeql_database_create([], lang="go")
6+
# Set up a GOPATH relative to this test's root directory;
7+
# we set os.environ instead of using extra_env because we
8+
# need it to be set for the call to "go clean -modcache" later
9+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
10+
os.environ['GOPATH'] = goPath
11+
run_codeql_database_create([], lang="go", source="src")
12+
13+
# Clean up the temporary GOPATH to prevent Bazel failures next
14+
# time the tests are run; see https://github.com/golang/go/issues/27161
15+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
#select
2+
| src/test.go:0:0:0:0 | src/test.go |
13
htmlFiles
24
extractionErrors
3-
#select
4-
| test.go:0:0:0:0 | test.go |
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45

5-
run_codeql_database_create([], lang="go")
6+
# Set up a GOPATH relative to this test's root directory;
7+
# we set os.environ instead of using extra_env because we
8+
# need it to be set for the call to "go clean -modcache" later
9+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
10+
os.environ['GOPATH'] = goPath
11+
run_codeql_database_create([], lang="go", source="src")
12+
13+
# Clean up the temporary GOPATH to prevent Bazel failures next
14+
# time the tests are run; see https://github.com/golang/go/issues/27161
15+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45
from diagnostics_test_utils import *
56

6-
run_codeql_database_create([], lang="go")
7+
# Set up a GOPATH relative to this test's root directory;
8+
# we set os.environ instead of using extra_env because we
9+
# need it to be set for the call to "go clean -modcache" later
10+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
11+
os.environ['GOPATH'] = goPath
12+
run_codeql_database_create([], lang="go", source="src")
713

814
check_diagnostics()
15+
16+
# Clean up the temporary GOPATH to prevent Bazel failures next
17+
# time the tests are run; see https://github.com/golang/go/issues/27161
18+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45
from diagnostics_test_utils import *
56

6-
run_codeql_database_create([], lang="go")
7+
# Set up a GOPATH relative to this test's root directory;
8+
# we set os.environ instead of using extra_env because we
9+
# need it to be set for the call to "go clean -modcache" later
10+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
11+
os.environ['GOPATH'] = goPath
12+
run_codeql_database_create([], lang="go", source="src")
713

814
check_diagnostics()
15+
16+
# Clean up the temporary GOPATH to prevent Bazel failures next
17+
# time the tests are run; see https://github.com/golang/go/issues/27161
18+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45
from diagnostics_test_utils import *
56

6-
run_codeql_database_create([], lang="go")
7+
# Set up a GOPATH relative to this test's root directory;
8+
# we set os.environ instead of using extra_env because we
9+
# need it to be set for the call to "go clean -modcache" later
10+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
11+
os.environ['GOPATH'] = goPath
12+
run_codeql_database_create([], lang="go", source="src")
713

814
check_diagnostics()
15+
16+
# Clean up the temporary GOPATH to prevent Bazel failures next
17+
# time the tests are run; see https://github.com/golang/go/issues/27161
18+
subprocess.call(["go", "clean", "-modcache"])
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
import sys
1+
import os
2+
import subprocess
23

34
from create_database_utils import *
45
from diagnostics_test_utils import *
56

6-
run_codeql_database_create([], lang="go")
7+
# Set up a GOPATH relative to this test's root directory;
8+
# we set os.environ instead of using extra_env because we
9+
# need it to be set for the call to "go clean -modcache" later
10+
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
11+
os.environ['GOPATH'] = goPath
12+
run_codeql_database_create([], lang="go", source="src")
713

814
check_diagnostics()
15+
16+
# Clean up the temporary GOPATH to prevent Bazel failures next
17+
# time the tests are run; see https://github.com/golang/go/issues/27161
18+
subprocess.call(["go", "clean", "-modcache"])

0 commit comments

Comments
 (0)