0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-31 09:14:20 -04:00
denoland-deno/tools/benchmark_test.py
Bartek Iwańczuk 43c6c1a9f5 Refactor test infrastructure (#2432)
* use subclass of unittest.TestCase for all test cases

* allow to run single test file (eg. python tools/integration_tests.py)

* test filtering (via --pattern/-p CLI flag)

* use common CLI parser for all tests:
  usage: test.py [-h] [--failfast] [--verbose] [--executable EXECUTABLE]
               [--release] [--pattern PATTERN] [--build-dir BUILD_DIR]

  optional arguments:
  -h, --help            show this help message and exit
  --failfast, -f        Stop on first failure
  --verbose, -v         Verbose output
  --executable EXECUTABLE
                        Use external executable of Deno
  --release             Test against release executable
  --pattern PATTERN, -p PATTERN
                        Run tests that match provided pattern
  --build-dir BUILD_DIR
                        Deno build directory

* respect NO_COLOR variable
2019-06-03 12:35:55 -04:00

59 lines
2 KiB
Python
Executable file

#!/usr/bin/env python
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import sys
import os
import benchmark
import unittest
from test_util import DenoTestCase, run_tests
class TestBenchmark(DenoTestCase):
def test_strace_parse(self):
with open(
os.path.join(sys.path[0], "testdata/strace_summary.out"),
"r") as f:
summary = benchmark.strace_parse(f.read())
# first syscall line
assert summary["munmap"]["calls"] == 60
assert summary["munmap"]["errors"] == 0
# line with errors
assert summary["mkdir"]["errors"] == 2
# last syscall line
assert summary["prlimit64"]["calls"] == 2
assert summary["prlimit64"]["% time"] == 0
# summary line
assert summary["total"]["calls"] == 704
def test_max_mem_parse(self):
with open(os.path.join(sys.path[0], "testdata/time.out"), "r") as f:
data = f.read()
assert benchmark.find_max_mem_in_bytes(data) == 120380 * 1024
def test_binary_size(self):
binary_size_dict = benchmark.get_binary_sizes(self.build_dir)
assert binary_size_dict["deno"] > 0
assert binary_size_dict["main.js"] > 0
assert binary_size_dict["main.js.map"] > 0
assert binary_size_dict["snapshot_deno.bin"] > 0
@unittest.skipIf("linux" not in sys.platform,
"strace only supported on linux")
def test_strace(self):
new_data = {}
benchmark.run_strace_benchmarks(self.deno_exe, new_data)
assert "thread_count" in new_data
assert "syscall_count" in new_data
s = new_data["thread_count"]
assert "hello" in s
assert s["hello"] > 1
s = new_data["syscall_count"]
assert "hello" in s
assert s["hello"] > 1
if __name__ == '__main__':
# FIME this doesn't appear to be the case.
# This test assumes tools/http_server.py is running in the background.
run_tests()