/
setup_test.rb
97 lines (79 loc) · 2.42 KB
/
setup_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# frozen_string_literal: true
require('test_helper')
module Bootsnap
class SetupTest < Minitest::Test
def setup
@_old_env = ENV.to_h
@tmp_dir = Dir.mktmpdir('bootsnap-test')
ENV['BOOTSNAP_CACHE_DIR'] = @tmp_dir
end
def teardown
ENV.replace(@_old_env)
end
def test_default_setup
Bootsnap.expects(:setup).with(
cache_dir: @tmp_dir,
development_mode: true,
load_path_cache: true,
compile_cache_iseq: Bootsnap.iseq_cache_supported?,
compile_cache_yaml: true,
compile_cache_json: true,
)
Bootsnap.default_setup
end
def test_default_setup_with_ENV_not_dev
ENV['ENV'] = 'something'
Bootsnap.expects(:setup).with(
cache_dir: @tmp_dir,
development_mode: false,
load_path_cache: true,
compile_cache_iseq: Bootsnap.iseq_cache_supported?,
compile_cache_yaml: true,
compile_cache_json: true,
)
Bootsnap.default_setup
end
def test_default_setup_with_DISABLE_BOOTSNAP_LOAD_PATH_CACHE
ENV['DISABLE_BOOTSNAP_LOAD_PATH_CACHE'] = 'something'
Bootsnap.expects(:setup).with(
cache_dir: @tmp_dir,
development_mode: true,
load_path_cache: false,
compile_cache_iseq: Bootsnap.iseq_cache_supported?,
compile_cache_yaml: true,
compile_cache_json: true,
)
Bootsnap.default_setup
end
def test_default_setup_with_DISABLE_BOOTSNAP_COMPILE_CACHE
ENV['DISABLE_BOOTSNAP_COMPILE_CACHE'] = 'something'
Bootsnap.expects(:setup).with(
cache_dir: @tmp_dir,
development_mode: true,
load_path_cache: true,
compile_cache_iseq: false,
compile_cache_yaml: false,
compile_cache_json: false,
)
Bootsnap.default_setup
end
def test_default_setup_with_DISABLE_BOOTSNAP
ENV['DISABLE_BOOTSNAP'] = 'something'
Bootsnap.expects(:setup).never
Bootsnap.default_setup
end
def test_default_setup_with_BOOTSNAP_LOG
ENV['BOOTSNAP_LOG'] = 'something'
Bootsnap.expects(:setup).with(
cache_dir: @tmp_dir,
development_mode: true,
load_path_cache: true,
compile_cache_iseq: Bootsnap.iseq_cache_supported?,
compile_cache_yaml: true,
compile_cache_json: true,
)
Bootsnap.expects(:logger=).with($stderr.method(:puts))
Bootsnap.default_setup
end
end
end