summaryrefslogtreecommitdiffhomepage
path: root/test/unit/check/go.py
blob: dd2150eb25cd7e23e3b394aeeb3672b429f133b4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import subprocess


def check_go(current_dir, temp_dir, test_dir):
    if not os.path.exists(temp_dir + '/go'):
        os.mkdir(temp_dir + '/go')

    env = os.environ.copy()
    env['GOPATH'] = current_dir + '/build/go'

    try:
        process = subprocess.Popen(
            [
                'go',
                'build',
                '-o',
                temp_dir + '/go/app',
                test_dir + '/go/empty/app.go',
            ],
            env=env,
        )
        process.communicate()

        if process.returncode == 0:
            return True

    except:
        return None