Diff of /codesys-ide/scripts/buildtest.py [ef9406] .. [61e89f]  Maximize  Restore

Switch to unified view

a/codesys-ide/scripts/buildtest.py b/codesys-ide/scripts/buildtest.py
...
...
2
import helper
2
import helper
3
3
4
# disable prompts, as those are enabled in UI mode by default
4
# disable prompts, as those are enabled in UI mode by default
5
system.prompt_handling = PromptHandling.None
5
system.prompt_handling = PromptHandling.None
6
6
7
# compile category GUID
8
CompileCategory = Guid("{97F48D64-A2A3-4856-B640-75C046E37EA9}")
9
10
7
def createtest(filename):
11
def createtest(filename):
8
    destination = filename + ".app"
12
    destination = filename + ".app"
9
    devId = None
13
    devId = None
10
    devices = device_repository.get_all_devices("CODESYS Control for Linux SL")
14
    devices = device_repository.get_all_devices("CODESYS Control for Linux SL")
11
    for device in devices:
15
    for device in devices:
...
...
14
18
15
    # check if this is a unit test project
19
    # check if this is a unit test project
16
    prg_runtest = proj.find('PRG_RUNTEST')
20
    prg_runtest = proj.find('PRG_RUNTEST')
17
    if len(prg_runtest) == 0:
21
    if len(prg_runtest) == 0:
18
        proj.close()
22
        proj.close()
23
        print("warning: no POU PRG_RUNTEST found. Will not create a test application.")
19
        return None
24
        return None
20
25
21
    # delete existing testdev device
26
    # delete existing testdev device
22
    existing = proj.find('testdev')
27
    existing = proj.find('testdev')
23
    if len(existing) > 0:
28
    if len(existing) > 0:
24
        existing[0].remove()
29
        existing[0].remove()
25
        
30
 
26
    # add device
31
    # add device
27
    proj.add('testdev', devId)
32
    proj.add('testdev', devId)
28
    apps = proj.find('Application', True)
33
    apps = proj.find('Application', True)
29
    if len(apps) > 0:
34
    if len(apps) > 0:
30
        app = apps[0]
35
        app = apps[0]
31
        tc = app.create_task_configuration()
36
        tc = app.create_task_configuration()
32
37
33
    # add task to call PRG_RUNTEST
38
    # add task to call PRG_RUNTEST
34
    task = tc.create_task('Task')
39
    task = tc.create_task('Task')
35
    task.pous.add('PRG_RUNTEST')
40
    task.pous.add('PRG_RUNTEST')
36
    
41
37
    helper.install_missing_libraries(proj, librarymanager)
42
    helper.install_missing_libraries(proj, librarymanager)
38
    #    proj.save()
43
    #    proj.save()
39
    print("create bootapp '%s'" % destination)
44
    print("create bootapp '%s'" % destination)
40
    proj.active_application.create_boot_application(destination)
45
    try:
46
        proj.active_application.create_boot_application(destination)
47
    except:
48
        print("Error: Creation of bootapplication failed")
49
        # Get message objects which contain all the data
50
        severities = {
51
            Severity.FatalError : "Fatal error", Severity.Error : "Error",
52
            Severity.Warning : "Warning", Severity.Information : "Information",
53
            Severity.Text : "Text"
54
        }
55
        msgs = system.get_message_objects(CompileCategory, Severity.FatalError|Severity.Error)
56
        for msg in msgs:
57
            sev = severities[msg.severity]
58
            print("{} {}{}: {}".format(sev, msg.prefix, msg.number, msg.text))
59
        return None
60
    print("done." % destination)
41
    proj.close()
61
    proj.close()
42
    return destination
62
    return destination
43
63
44
64
45
class SearchBuildDo(helper.SearchBuild):
65
class SearchBuildDo(helper.SearchBuild):
46
    # Test rules for:
66
    # Test rules for:
47
    # - *.library
67
    # - *.library
48
    def doit(self, filename):
68
    def doit(self, filename):
49
        artifacts = list()
69
        artifacts = list()
50
        helper.install_requirements(filename, librarymanager)
70
        helper.install_requirements(filename, librarymanager)
51
        
71
52
        if filename.endswith(".library"):
72
        if filename.endswith(".library"):
53
            print("\n\n*** Create test application for: %s" % filename)
73
            print("\n\n*** Create test application for: %s" % filename)
54
            proj = projects.open(filename)
74
            proj = projects.open(filename)
55
            artifact = createtest(filename)
75
            artifact = createtest(filename)
56
            if artifact != None:
76
            if artifact != None: