Skip to content

Go: Improve robustness of integration tests #15355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#select
| src/test.go:0:0:0:0 | src/test.go |
| src/todel.go:0:0:0:0 | src/todel.go |
htmlFiles
extractionErrors
| Extraction failed in test.go with error \tother declaration of test | 2 |
| Extraction failed in todel.go with error test redeclared in this block | 2 |
#select
| test.go:0:0:0:0 | test.go |
| todel.go:0:0:0:0 | todel.go |
15 changes: 13 additions & 2 deletions go/ql/integration-tests/all-platforms/go/bazel-sample-1/test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import sys
import os
import subprocess

from create_database_utils import *
from diagnostics_test_utils import *

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

run_codeql_database_create([], lang="go", source="src")

check_diagnostics()

# Clean up the temporary GOPATH to prevent Bazel failures next
# time the tests are run; see https://github.com/golang/go/issues/27161
subprocess.call(["go", "clean", "-modcache"])
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#select
| src/test.go:0:0:0:0 | src/test.go |
| src/todel.go:0:0:0:0 | src/todel.go |
htmlFiles
extractionErrors
| Extraction failed in test.go with error \tother declaration of test | 2 |
| Extraction failed in todel.go with error test redeclared in this block | 2 |
#select
| test.go:0:0:0:0 | test.go |
| todel.go:0:0:0:0 | todel.go |
15 changes: 13 additions & 2 deletions go/ql/integration-tests/all-platforms/go/bazel-sample-2/test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import sys
import os
import subprocess

from create_database_utils import *
from diagnostics_test_utils import *

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

run_codeql_database_create([], lang="go", source="src")

check_diagnostics()

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

from create_database_utils import *
from diagnostics_test_utils import *

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

check_diagnostics()

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

from create_database_utils import *
from diagnostics_test_utils import *

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

check_diagnostics()

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

from create_database_utils import *
from diagnostics_test_utils import *

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

check_diagnostics()

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

from create_database_utils import *
from diagnostics_test_utils import *

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

check_diagnostics()

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

from create_database_utils import *
from diagnostics_test_utils import *

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

check_diagnostics()

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

from create_database_utils import *
from diagnostics_test_utils import *

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

check_diagnostics()

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

from create_database_utils import *
from diagnostics_test_utils import *

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

check_diagnostics()

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

from create_database_utils import *

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

# Clean up the temporary GOPATH to prevent Bazel failures next
# time the tests are run; see https://github.com/golang/go/issues/27161
subprocess.call(["go", "clean", "-modcache"])
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#select
| src/test.go:0:0:0:0 | src/test.go |
htmlFiles
extractionErrors
#select
| test.go:0:0:0:0 | test.go |
14 changes: 12 additions & 2 deletions go/ql/integration-tests/all-platforms/go/go-mod-sample/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import sys
import os
import subprocess

from create_database_utils import *

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

# Clean up the temporary GOPATH to prevent Bazel failures next
# time the tests are run; see https://github.com/golang/go/issues/27161
subprocess.call(["go", "clean", "-modcache"])
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#select
| src/test.go:0:0:0:0 | src/test.go |
htmlFiles
extractionErrors
#select
| test.go:0:0:0:0 | test.go |
14 changes: 12 additions & 2 deletions go/ql/integration-tests/all-platforms/go/make-sample/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import sys
import os
import subprocess

from create_database_utils import *

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

# Clean up the temporary GOPATH to prevent Bazel failures next
# time the tests are run; see https://github.com/golang/go/issues/27161
subprocess.call(["go", "clean", "-modcache"])
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#select
| src/test.go:0:0:0:0 | src/test.go |
htmlFiles
extractionErrors
#select
| test.go:0:0:0:0 | test.go |
14 changes: 12 additions & 2 deletions go/ql/integration-tests/all-platforms/go/ninja-sample/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import sys
import os
import subprocess

from create_database_utils import *

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

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

from create_database_utils import *
from diagnostics_test_utils import *

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

check_diagnostics()

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

from create_database_utils import *
from diagnostics_test_utils import *

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

check_diagnostics()

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

from create_database_utils import *
from diagnostics_test_utils import *

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

check_diagnostics()

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

from create_database_utils import *
from diagnostics_test_utils import *

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

check_diagnostics()

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