Skip to content

Commit fab0b1d

Browse files
authored
Fix lnt startup crash on Windows (#32)
Running lnt on Windows fails with an Error as it tries to import the resource module which is not available on windows. This patch fixes the crash by making the resource module an optional dependency. We dont have python module that exposes any function to get the cpu times of child processes (make.exe + clang-cl.exe + lld.exe). Thus using wall clock time will be a better alternate. Also nt TestModule is only used by SPEC when run from llvm-test-suite and we dont support it on windows.
1 parent 5b02472 commit fab0b1d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lnt/tests/nt.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
import urllib.error
1313
import shlex
1414
import pipes
15-
import resource
15+
16+
try:
17+
import resource
18+
has_resource = True
19+
except ImportError:
20+
has_resource = False
1621

1722
import click
1823

@@ -73,7 +78,8 @@ def call(self, args, **kwargs):
7378
return p.wait()
7479

7580
def get_time(self):
76-
if self._user_time:
81+
# Only get the user time if the 'resource' module is available.
82+
if self._user_time and has_resource:
7783
return resource.getrusage(resource.RUSAGE_CHILDREN).ru_utime
7884
else:
7985
return time.time()

0 commit comments

Comments
 (0)