GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage/nodes/benchmark/out/../src/node_config.cc Lines: 38 38 100.0 %
Date: 2019-01-07 12:15:22 Branches: 18 18 100.0 %

Line Branch Exec Source
1
#include "node.h"
2
#include "node_i18n.h"
3
#include "node_options-inl.h"
4
#include "env-inl.h"
5
#include "util-inl.h"
6
7
namespace node {
8
9
using v8::Boolean;
10
using v8::Context;
11
using v8::Integer;
12
using v8::Isolate;
13
using v8::Local;
14
using v8::Number;
15
using v8::Object;
16
using v8::Value;
17
18
// The config binding is used to provide an internal view of compile or runtime
19
// config options that are required internally by lib/*.js code. This is an
20
// alternative to dropping additional properties onto the process object as
21
// has been the practice previously in node.cc.
22
23
3671
static void Initialize(Local<Object> target,
24
                       Local<Value> unused,
25
                       Local<Context> context) {
26
3671
  Environment* env = Environment::GetCurrent(context);
27
3671
  Isolate* isolate = env->isolate();
28
29
#if defined(DEBUG) && DEBUG
30
  READONLY_TRUE_PROPERTY(target, "isDebugBuild");
31
#else
32
11013
  READONLY_FALSE_PROPERTY(target, "isDebugBuild");
33
#endif  // defined(DEBUG) && DEBUG
34
35
#if HAVE_OPENSSL
36
11013
  READONLY_TRUE_PROPERTY(target, "hasOpenSSL");
37
#else
38
  READONLY_FALSE_PROPERTY(target, "hasOpenSSL");
39
#endif  // HAVE_OPENSSL
40
41
#ifdef NODE_FIPS_MODE
42
  READONLY_TRUE_PROPERTY(target, "fipsMode");
43
  // TODO(addaleax): Use options parser variable instead.
44
  if (per_process_opts->force_fips_crypto)
45
    READONLY_TRUE_PROPERTY(target, "fipsForced");
46
#endif
47
48
#ifdef NODE_HAVE_I18N_SUPPORT
49
50
11013
  READONLY_TRUE_PROPERTY(target, "hasIntl");
51
52
#ifdef NODE_HAVE_SMALL_ICU
53
11013
  READONLY_TRUE_PROPERTY(target, "hasSmallICU");
54
#endif  // NODE_HAVE_SMALL_ICU
55
56
#if NODE_USE_V8_PLATFORM
57
11013
  READONLY_TRUE_PROPERTY(target, "hasTracing");
58
#endif
59
60
#if HAVE_INSPECTOR
61
11013
  READONLY_TRUE_PROPERTY(target, "hasInspector");
62
#else
63
  READONLY_FALSE_PROPERTY(target, "hasInspector");
64
#endif
65
66
#if !defined(NODE_WITHOUT_NODE_OPTIONS)
67
11013
  READONLY_TRUE_PROPERTY(target, "hasNodeOptions");
68
#endif
69
70
#endif  // NODE_HAVE_I18N_SUPPORT
71
72
3671
  if (env->options()->preserve_symlinks)
73
33
    READONLY_TRUE_PROPERTY(target, "preserveSymlinks");
74
3671
  if (env->options()->preserve_symlinks_main)
75
6
    READONLY_TRUE_PROPERTY(target, "preserveSymlinksMain");
76
77
3671
  if (env->options()->experimental_modules) {
78
150
    READONLY_TRUE_PROPERTY(target, "experimentalModules");
79
50
    const std::string& userland_loader = env->options()->userland_loader;
80
50
    if (!userland_loader.empty()) {
81
44
      READONLY_STRING_PROPERTY(target, "userLoader",  userland_loader);
82
    }
83
  }
84
85
3671
  if (env->options()->experimental_vm_modules)
86
24
    READONLY_TRUE_PROPERTY(target, "experimentalVMModules");
87
88
3671
  if (env->options()->experimental_worker)
89
498
    READONLY_TRUE_PROPERTY(target, "experimentalWorker");
90
91
3671
  if (env->options()->experimental_repl_await)
92
3
    READONLY_TRUE_PROPERTY(target, "experimentalREPLAwait");
93
94
3671
  if (env->options()->expose_internals)
95
750
    READONLY_TRUE_PROPERTY(target, "exposeInternals");
96
97
3671
  if (env->abort_on_uncaught_exception())
98
57
    READONLY_TRUE_PROPERTY(target, "shouldAbortOnUncaughtException");
99
100
14684
  READONLY_PROPERTY(target,
101
                    "bits",
102
                    Number::New(env->isolate(), 8 * sizeof(intptr_t)));
103
104
3671
  Local<Object> debug_options_obj = Object::New(isolate);
105
11013
  READONLY_PROPERTY(target, "debugOptions", debug_options_obj);
106
107
3671
  const DebugOptions& debug_options = env->options()->debug_options();
108
14684
  READONLY_PROPERTY(debug_options_obj,
109
                    "inspectorEnabled",
110
                    Boolean::New(isolate, debug_options.inspector_enabled));
111
14684
  READONLY_STRING_PROPERTY(
112
      debug_options_obj, "host", debug_options.host_port.host());
113
14684
  READONLY_PROPERTY(debug_options_obj,
114
                    "port",
115
                    Integer::New(isolate, debug_options.host_port.port()));
116
3671
}  // InitConfig
117
118
}  // namespace node
119
120
3596
NODE_MODULE_CONTEXT_AWARE_INTERNAL(config, node::Initialize)