forked from nico/ninjatracing
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor for testability, add simple test
- Loading branch information
Showing
3 changed files
with
55 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ninjatracing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env python | ||
|
||
import ninjatracing | ||
import unittest | ||
|
||
try: | ||
from StringIO import StringIO | ||
except ImportError: | ||
from io import StringIO | ||
|
||
class TestNinjaTracing(unittest.TestCase): | ||
|
||
def test_simple(self): | ||
log = StringIO("# ninja log v5\n" | ||
"100\t200\t0\tmy_output\tdeadbeef\n" | ||
"50\t120\t0\tmy_first_output\t0afef\n") | ||
dicts = list(ninjatracing.log_to_dicts(log, 42)) | ||
expected = [ | ||
{ | ||
'name': 'my_first_output', 'cat': 'targets', 'ph': 'X', | ||
'ts': '50000', 'dur': '70000', 'pid': '42', 'tid': '0', | ||
'args': {} | ||
}, | ||
{ | ||
'name': 'my_output', 'cat': 'targets', 'ph': 'X', | ||
'ts': '100000', 'dur': '100000', 'pid': '42', 'tid': '1', | ||
'args': {} | ||
}, | ||
] | ||
self.assertEqual(expected, dicts) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |