phusion passenger install hangs building CoreMain.cpp - rake

On ubuntu-20 with ruby-2.6.6 and -3.0.4 installed via chruby, I have previously installed passenger 6.0.14 under 3.0.4. I need to install it (build mod_passenger.so) under ruby 2.6.6.
When I attempt to install, it hangs when compiling CoreMain.cpp.
The build process is started as follows:
Compiling and installing Apache 2 module...
cd /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.14
# env NOEXEC_DISABLE=1 /opt/rubies/ruby-2.6.6/bin/ruby /opt/rubies/ruby-2.6.6/bin/rake RELEASE=yes apache2:clean apache2
rm -rf buildout/cache
...
It starts off building fine, but appears to slow down as it progresses.
At the end, it took 3 min to compile WatchdogMain.cpp, then starts on CoreMain.cpp.
After 20 minutes working on CoreMain.cpp, I get the following traceback when I interrupt the process:
c++ -o buildout/support-binaries/CoreMain.o -Isrc/agent -Isrc/cxx_supportlib -Isrc/cxx_supportlib/vendor-copy -Isrc/cxx_supportlib/vendor-modified -Isrc/cxx_supportlib/vendor-modified/libev -Isrc/cxx_supportlib/vendor-copy/libuv/include -Isrc/cxx_supportlib/vendor-modified/websocketpp -D_REENTRANT -I/usr/local/include -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-long-long -Wno-missing-field-initializers -feliminate-unused-debug-symbols -feliminate-unused-debug-types -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -Wno-attributes -DHAS_ALLOCA_H -DHAVE_ACCEPT4 -DHAS_SFENCE -DHAS_LFENCE -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -ggdb -std=gnu++11 -Wno-unused-local-typedefs -Wno-format-nonliteral -DHAS_UNORDERED_MAP -c src/agent/Core/CoreMain.cpp
^C^C^C^CTraceback (most recent call last):
9: from /opt/rubies/ruby-2.6.6/bin/passenger-install-apache2-module:23:in `<main>'
8: from /opt/rubies/ruby-2.6.6/bin/passenger-install-apache2-module:23:in `load'
7: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.14/bin/passenger-install-apache2-module:964:in `<top (required)>'
6: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.14/src/ruby_supportlib/phusion_passenger/abstract_installer.rb:74:in `run'
5: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.14/bin/passenger-install-apache2-module:149:in `run_steps'
4: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.14/bin/passenger-install-apache2-module:424:in `compile_apache2_module'
3: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.14/src/ruby_supportlib/phusion_passenger/abstract_installer.rb:415:in `sh'
2: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.14/src/ruby_supportlib/phusion_passenger/abstract_installer.rb:415:in `system'
1: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.14/src/ruby_supportlib/phusion_passenger/abstract_installer.rb:415:in `initialize'
/opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.14/src/ruby_supportlib/phusion_passenger/abstract_installer.rb:415:in `initialize': Interrupt
/opt/rubies/ruby-2.6.6/bin/passenger-install-apache2-module: Interrupt
rake aborted!
Interrupt:
Tasks: TOP => apache2 => buildout/support-binaries/PassengerAgent => buildout/support-binaries/CoreMain.o
(See full trace by running task with --trace)
Traceback (most recent call last):
36: from /opt/rubies/ruby-2.6.6/bin/rake:23:in `<main>'
35: from /opt/rubies/ruby-2.6.6/bin/rake:23:in `load'
34: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
33: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:80:in `run'
32: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
31: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:83:in `block in run'
30: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:110:in `top_level'
29: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:125:in `run_with_threads'
28: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:116:in `block in top_level'
27: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:116:in `each'
26: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:116:in `block (2 levels) in top_level'
25: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:160:in `invoke_task'
24: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:183:in `invoke'
23: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:194:in `invoke_with_call_chain'
22: from /opt/rubies/ruby-2.6.6/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
21: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:213:in `block in invoke_with_call_chain'
20: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:236:in `invoke_prerequisites'
19: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:236:in `each'
18: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:238:in `block in invoke_prerequisites'
17: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:194:in `invoke_with_call_chain'
16: from /opt/rubies/ruby-2.6.6/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
15: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:213:in `block in invoke_with_call_chain'
14: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:236:in `invoke_prerequisites'
13: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:236:in `each'
12: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:238:in `block in invoke_prerequisites'
11: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:194:in `invoke_with_call_chain'
10: from /opt/rubies/ruby-2.6.6/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
9: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:214:in `block in invoke_with_call_chain'
8: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:273:in `execute'
7: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:273:in `each'
6: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task.rb:273:in `block in execute'
5: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.14/build/support/cplusplus.rb:162:in `block in define_cxx_object_compilation_task'
4: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.14/build/support/cplusplus.rb:104:in `compile_cxx'
3: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.14/build/support/cplusplus.rb:31:in `run_compiler'
2: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.14/build/support/cplusplus.rb:31:in `system'
1: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.14/build/support/cplusplus.rb:31:in `initialize'
/opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.14/build/support/cplusplus.rb:31:in `initialize': Interrupt
7: from /opt/rubies/ruby-2.6.6/bin/rake:23:in `<main>'
6: from /opt/rubies/ruby-2.6.6/bin/rake:23:in `load'
5: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
4: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:80:in `run'
3: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:185:in `standard_exception_handling'
2: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:196:in `rescue in standard_exception_handling'
1: from /opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:202:in `exit_because_of_exception'
/opt/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:202:in `exit': exit (SystemExit)
/opt/rubies/ruby-2.6.6/bin/rake: Interrupt

Related

How to subtract values in fastlane?

In my Fastfile I have method:
lane :calculate_build_version do
ENV['BUILD_NUMBER'] - BuildNumberFactory.make
end
BuldNumberFactory code is:
class BuildNumberFactory
class << self
def make
`git rev-list HEAD --count`
end
end
end
During build I get error:
Fastfile:22:in `block (2 levels) in parsing_binding': [!] undefined method `-' for "192":String (NoMethodError)
How can I fix this and perform subtract?

Mapbox in Android - Black color around GEOTiff raster layers

Goal
I need to add some aeronautical layers taken from FAA to the map. The layers are provided as GeoTIFF files.
Steps
Downloaded a GeoTiff file from FAA website.
Using QGis app clipped the legend from the file. Actually the issue occurs without this step as well.
Reprojected it to EPSG:3857 using GDAL command gdalwarp -q -t_srs EPSG:3857 -dstalpha -of vrt Albuquerque\ SEC\ 104-cut.tif /vsistdout/ | gdal_translate -co compress=lzw /vsistdin/ Albuquerque\ SEC\ 104-north-up-cut.tif. Otherwise I got Error creating Mapnik Datasource: Invalid raster: Invalid rotation value in geotransform array when uploading to Mapbox.
Created a Tileset by uploading GeoTIFFs to Mapbox.
Created a new style in the Mapbox Studio.
Added the tilesets as layers.
Mapbox Studio Result
The map is showing well in Mapbox Studio:
Android Result
However in Android app this style shows with some black borders of random width depending on zoom level and camera position.
Here is how it looks in android:
I tried it on Pixel 3a (Android 10), Nexus 5x (Android 8.1) and Android emulator (Android 10). I have good internet connection and gave it enough time so the tiles are loaded.
The source code where the map is embedded is official Demo app. I just replaced token and style URL:
mapView.getMapAsync(new OnMapReadyCallback() {
#Override
public void onMapReady(#NonNull MapboxMap mapboxMap) {
DefaultStyleActivity.this.mapboxMap = mapboxMap;
mapboxMap.setStyle("mapbox://styles/rustamg/ck8se724l23bh1io2b1hnbqls");
}
});
Here is GDALInfo for the GEOTiff I uploaded:
Driver: GTiff/GeoTIFF
Files: /Users/me/Desktop/Dev/Albuquerque SEC 104-north-up-cut.tif
Size is 16104, 11408
Coordinate System is:
PROJCS["WGS 84 / Pseudo-Mercator",
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]],
PROJECTION["Mercator_1SP"],
PARAMETER["central_meridian",0],
PARAMETER["scale_factor",1],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
AXIS["X",EAST],
AXIS["Y",NORTH],
EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=#null +wktext +no_defs"],
AUTHORITY["EPSG","3857"]]
Origin = (-12154316.342745549976826,4340308.343459489755332)
Pixel Size = (51.194510520863538,-51.194510520863538)
Metadata:
AREA_OR_POINT=Area
TIFFTAG_DATETIME=2019:09:03 09:02:22
TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
TIFFTAG_SOFTWARE=Adobe Photoshop CC (Windows)
TIFFTAG_XRESOLUTION=300
TIFFTAG_YRESOLUTION=300
Image Structure Metadata:
COMPRESSION=LZW
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left (-12154316.343, 4340308.343) (109d11' 2.69"W, 36d17'16.43"N)
Lower Left (-12154316.343, 3756281.367) (109d11' 2.69"W, 31d56'47.16"N)
Upper Right (-11329879.945, 4340308.343) (101d46'40.96"W, 36d17'16.43"N)
Lower Right (-11329879.945, 3756281.367) (101d46'40.96"W, 31d56'47.16"N)
Center (-11742098.144, 4048294.855) (105d28'51.82"W, 34d 8'42.17"N)
Band 1 Block=16104x1 Type=Byte, ColorInterp=Palette
Mask Flags: PER_DATASET ALPHA
Color Table (RGB with 256 entries)
0: 255,255,255,255
1: 255,255,0,255
2: 255,0,255,255
3: 255,0,0,255
4: 0,255,255,255
5: 0,255,0,255
6: 0,0,255,255
7: 0,0,0,255
8: 252,252,254,255
9: 255,255,1,255
10: 252,236,170,255
11: 248,228,166,255
12: 228,200,154,255
13: 154,81,86,255
14: 120,103,105,255
15: 221,135,154,255
16: 166,87,106,255
17: 107,86,91,255
18: 172,104,124,255
19: 79,9,35,255
20: 141,59,88,255
21: 126,12,61,255
22: 229,107,161,255
23: 200,150,173,255
24: 234,178,204,255
25: 100,8,53,255
26: 200,81,137,255
27: 146,68,105,255
28: 136,38,88,255
29: 98,29,64,255
30: 190,113,151,255
31: 119,44,83,255
32: 214,182,199,255
33: 177,144,163,255
34: 116,13,75,255
35: 33,8,25,255
36: 143,116,141,255
37: 232,216,232,255
38: 248,232,248,255
39: 77,26,86,255
40: 75,69,104,255
41: 105,103,125,255
42: 40,36,105,255
43: 8,8,24,255
44: 232,232,248,255
45: 120,120,122,255
46: 8,14,85,255
47: 203,204,216,255
48: 60,62,80,255
49: 8,22,115,255
50: 86,88,104,255
51: 180,184,201,255
52: 8,54,179,255
53: 8,40,120,255
54: 28,56,120,255
55: 8,40,104,255
56: 143,152,171,255
57: 8,54,136,255
58: 37,47,65,255
59: 184,201,232,255
60: 25,72,152,255
61: 202,214,233,255
62: 31,56,95,255
63: 8,84,182,255
64: 8,72,158,255
65: 8,56,120,255
66: 9,42,86,255
67: 25,72,136,255
68: 37,88,152,255
69: 51,75,104,255
70: 11,100,202,255
71: 8,23,40,255
72: 27,72,120,255
73: 8,56,104,255
74: 44,88,133,255
75: 184,198,212,255
76: 80,84,88,255
77: 8,72,133,255
78: 22,104,178,255
79: 71,121,168,255
80: 91,134,173,255
81: 43,121,184,255
82: 80,113,140,255
83: 8,88,152,255
84: 24,88,136,255
85: 53,104,143,255
86: 8,88,136,255
87: 22,104,149,255
88: 114,144,162,255
89: 139,172,191,255
90: 104,124,134,255
91: 146,205,232,255
92: 136,197,216,255
93: 134,184,201,255
94: 153,200,216,255
95: 135,216,232,255
96: 85,105,109,255
97: 213,233,236,255
98: 152,195,200,255
99: 167,216,221,255
100: 181,232,237,255
101: 151,233,237,255
102: 8,24,24,255
103: 230,248,248,255
104: 182,183,183,255
105: 184,217,216,255
106: 120,136,134,255
107: 24,40,37,255
108: 174,207,200,255
109: 143,147,145,255
110: 225,248,232,255
111: 103,120,104,255
112: 8,24,8,255
113: 87,104,86,255
114: 212,232,210,255
115: 181,200,175,255
116: 163,171,158,255
117: 229,248,216,255
118: 198,216,184,255
119: 147,172,126,255
120: 231,248,200,255
121: 200,216,168,255
122: 216,232,178,255
123: 200,216,151,255
124: 232,248,184,255
125: 212,232,146,255
126: 232,248,167,255
127: 189,207,105,255
128: 199,200,152,255
129: 248,248,71,255
130: 24,24,8,255
131: 145,144,57,255
132: 248,248,104,255
133: 216,216,135,255
134: 248,248,168,255
135: 200,200,136,255
136: 216,216,152,255
137: 232,232,168,255
138: 248,248,184,255
139: 216,216,168,255
140: 232,232,184,255
141: 248,248,200,255
142: 200,200,168,255
143: 120,120,101,255
144: 232,232,200,255
145: 248,248,216,255
146: 216,216,193,255
147: 200,200,184,255
148: 232,232,216,255
149: 248,248,232,255
150: 170,168,56,255
151: 201,194,72,255
152: 179,174,78,255
153: 229,223,101,255
154: 214,205,88,255
155: 196,189,104,255
156: 232,218,133,255
157: 246,233,151,255
158: 42,40,29,255
159: 148,136,82,255
160: 200,184,120,255
161: 216,200,136,255
162: 232,216,152,255
163: 248,232,168,255
164: 165,152,104,255
165: 114,106,76,255
166: 182,173,141,255
167: 248,216,115,255
168: 183,168,119,255
169: 147,139,114,255
170: 200,168,72,255
171: 216,184,88,255
172: 200,184,136,255
173: 216,200,152,255
174: 232,216,168,255
175: 248,232,184,255
176: 228,184,72,255
177: 200,168,88,255
178: 216,184,104,255
179: 81,74,58,255
180: 248,188,71,255
181: 232,185,88,255
182: 248,199,101,255
183: 200,168,104,255
184: 216,184,120,255
185: 232,200,136,255
186: 248,216,152,255
187: 168,152,120,255
188: 200,184,152,255
189: 216,200,168,255
190: 232,216,184,255
191: 219,167,72,255
192: 178,144,82,255
193: 248,231,200,255
194: 184,136,56,255
195: 216,168,88,255
196: 232,185,104,255
197: 248,200,123,255
198: 220,150,49,255
199: 130,93,40,255
200: 200,152,84,255
201: 184,152,104,255
202: 200,168,120,255
203: 216,184,136,255
204: 232,200,152,255
205: 248,216,168,255
206: 179,119,36,255
207: 160,114,54,255
208: 216,168,104,255
209: 232,184,120,255
210: 200,137,56,255
211: 232,168,88,255
212: 61,53,43,255
213: 146,115,80,255
214: 216,168,120,255
215: 248,200,152,255
216: 168,136,104,255
217: 184,152,120,255
218: 200,168,136,255
219: 216,184,152,255
220: 232,200,168,255
221: 248,216,184,255
222: 216,200,184,255
223: 248,232,216,255
224: 110,87,68,255
225: 248,184,135,255
226: 170,151,137,255
227: 184,136,104,255
228: 200,152,120,255
229: 216,168,136,255
230: 232,184,150,255
231: 248,200,168,255
232: 171,114,77,255
233: 168,136,120,255
234: 232,200,184,255
235: 200,183,174,255
236: 232,164,134,255
237: 200,168,154,255
238: 248,167,139,255
239: 171,119,104,255
240: 216,168,154,255
241: 184,133,121,255
242: 140,117,111,255
243: 232,213,208,255
244: 201,148,137,255
245: 235,181,172,255
246: 216,138,126,255
247: 41,24,23,255
248: 24,8,8,255
249: 248,232,232,255
250: 201,200,200,255
251: 248,248,248,255
252: 232,232,232,255
253: 104,104,104,255
254: 24,24,24,255
255: 8,8,8,255
Band 2 Block=16104x1 Type=Byte, ColorInterp=Alpha
Question
How can I get rid of those black issues?
I'd be happy to provide more info if needed.
Update 2020-05-06
I tried what's suggested in troubleshooting page: both prepare tileset and create RasterSource within Android app. The first command rio calc "(asarray (take a 1) (take a 2) (take a 3))" --co compress=lzw --co tiled=true --co blockxsize=256 --co blockysize=256 --name a=filename.tif filename255.tif failed with an error:
IndexError: index 1 is out of bounds for size 1
However my tif already uses LZW compression. So I tried the second command:
rio edit-info --nodata 0 filename255.tif
and uploaded the result to Mapbox.
The result was the same except that white background of the image became black as well:
I also tried the same steps with smaller image (409x306) as it's pointed here that Android has texture size limitation. The result is all the same:
The black borders should be transparent, but the raster image format Mapbox is using (JPG) does not support transparency, which is a known issue that exists in every gl-native-based SDK. This issue presents itself when you reference a style that has the raster layer built in.
As a workaround, you can follow Mapbox's troubleshooting guide on troubleshooting raster images with black backgrounds to make your tileset transparent and then add the tileset as a RasterSource within your Android application to display the raster tile as expected.
Please take a look at the following example as a reference for adding a RasterSource:
Add a WMS Source
Instead of calling the rasterSource using "mapbox://username.tilesetID", you need to call it similarly to the Add a WMS Source example. The code below will resolve your issue:
style.addSource(RasterSource( "albuquerque-source", TileSet( "tileset", "https://api.mapbox.com/v4/<username.tilesetID>/{z}/{x}/{y}.png?access_token=<your_access_token>" ), 256 ))

Ionic CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory while starting new project

I am new to Ionic I am getting below error when I am creating any new project.
Could any one help me to fix this issue?
==== JS stack trace =========================================
Security context: 0x1240acccf781 <JS Object>
1: build [/usr/local/lib/node_modules/ionic/node_modules/chalk/index.js:118] [pc=0x185922bbdfc] (this=0x1883445b3691 <JS Function Chalk.chalk.template (SharedFunctionInfo 0x1883445b3199)>,_styles=0x36dd597b5061 <JS Array[1]>,key=0x1240acc57f81 <String[4]: bold>)
2: _onTimeout [/usr/local/lib/node_modules/ionic/node_modules/#ionic/cli-utils/lib/utils/task.js:~111] [pc=0x18592337f60] (thi...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [ionic]
2: 0x109f0ac [ionic]
3: v8::Utils::ReportApiFailure(char const*, char const*) [ionic]
4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [ionic]
5: v8::internal::Factory::NewTransitionArray(int) [ionic]
6: v8::internal::TransitionArray::Insert(v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Map>, v8::internal::SimpleTransitionFlag) [ionic]
7: v8::internal::Map::CopyReplaceDescriptors(v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::DescriptorArray>, v8::internal::Handle<v8::internal::LayoutDescriptor>, v8::internal::TransitionFlag, v8::internal::MaybeHandle<v8::internal::Name>, char const*, v8::internal::SimpleTransitionFlag) [ionic]
8: v8::internal::Map::CopyAddDescriptor(v8::internal::Handle<v8::internal::Map>, v8::internal::Descriptor*, v8::internal::TransitionFlag) [ionic]
9: v8::internal::Map::CopyWithField(v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::FieldType>, v8::internal::PropertyAttributes, v8::internal::Representation, v8::internal::TransitionFlag) [ionic]
10: v8::internal::Map::TransitionToDataProperty(v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::Object::StoreFromKeyed) [ionic]
11: v8::internal::LookupIterator::PrepareTransitionToDataProperty(v8::internal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::Object::StoreFromKeyed) [ionic]
12: v8::internal::StoreIC::LookupForWrite(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::Object::StoreFromKeyed) [ionic]
13: v8::internal::StoreIC::UpdateCaches(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::Object::StoreFromKeyed) [ionic]
14: v8::internal::StoreIC::Store(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Object>, v8::internal::Object::StoreFromKeyed) [ionic]
15: v8::internal::Runtime_StoreIC_Miss(int, v8::internal::Object**, v8::internal::Isolate*) [ionic]
16: 0x185921092a7
Aborted (core dumped)
Try with the following command:
$node --max-old-space-size=4096 /usr/local/bin/ionic cordova build android --prod

Is multiple assignment of tuples slower than multiple assignment statements?

Is there a difference between assigning multiple variables using a tuple, and assigning them in multiple statements?
For example, is there a difference between the following code snippets?
// multiple assignment using tuples
val (x, y) = (str.length, str.substring(1, 2))
// multiple-statement assignment
val x = str.length
val y = str.substring(1, 2)
There is a difference. The approach of using tuples is actually invoking an extractor (the unapply method), which would incur a cost at runtime. The second approach is certainly faster.
To get an idea about the difference, here is a decompilation of two methods showing both approaches. You can see clearly how the first approach causes much more operations.
An important point to note here is that the first expression requires auto-boxing to a java.lang.Integer (because Tuple2 accepts objects), while the second expression uses the value without boxing.
public void m1(java.lang.String);
Code:
0: new #16 // class scala/Tuple2
3: dup
4: aload_1
5: invokevirtual #22 // Method java/lang/String.length:()I
8: invokestatic #28 // Method scala/runtime/BoxesRunTime.boxToInteger:(I)Ljava/lang/Integer;
11: aload_1
12: iconst_1
13: iconst_2
14: invokevirtual #32 // Method java/lang/String.substring:(II)Ljava/lang/String;
17: invokespecial #35 // Method scala/Tuple2."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
20: astore_3
21: aload_3
22: ifnull 75
25: aload_3
26: invokevirtual #38 // Method scala/Tuple2._1$mcI$sp:()I
29: istore 4
31: aload_3
32: invokevirtual #42 // Method scala/Tuple2._2:()Ljava/lang/Object;
35: checkcast #18 // class java/lang/String
38: astore 5
40: new #16 // class scala/Tuple2
43: dup
44: iload 4
46: invokestatic #28 // Method scala/runtime/BoxesRunTime.boxToInteger:(I)Ljava/lang/Integer;
49: aload 5
51: invokespecial #35 // Method scala/Tuple2."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
54: astore 6
56: aload 6
58: astore_2
59: aload_2
60: invokevirtual #38 // Method scala/Tuple2._1$mcI$sp:()I
63: istore 7
65: aload_2
66: invokevirtual #42 // Method scala/Tuple2._2:()Ljava/lang/Object;
69: checkcast #18 // class java/lang/String
72: astore 8
74: return
75: new #44 // class scala/MatchError
78: dup
79: aload_3
80: invokespecial #47 // Method scala/MatchError."<init>":(Ljava/lang/Object;)V
83: athrow
public void m2(java.lang.String);
Code:
0: aload_1
1: invokevirtual #22 // Method java/lang/String.length:()I
4: istore_2
5: aload_1
6: iconst_1
7: iconst_2
8: invokevirtual #32 // Method java/lang/String.substring:(II)Ljava/lang/String;
11: astore_3
12: return
}

Test passes with `testrb`, but crashes using Rails `rake test`?

I have a simple test to check that a carrierwave uploader works.
I use minitest for this, and the test works when run on its own, but not under Rails’s rake test... environment.
(Code for the test is included below.)
Things that work:
If I run ruby test/uploaders/image_file_uploader_test.rb the test passes.
If I run testrb test/uploaders/image_file_uploader_test.rb the test passes.
If I manually call all the lines in the test from IRB (not the Rails console), the code does what’s expected
If I create a small Rake TestTask to run the file (task also copied below), the test passes.
Things that do not work:
If I call rake test test/uploaders/image_file_uploader_test.rb I get dropped into the debugger (stack trace below)
If I call zeus rake test test/uploaders/image_file_uploader_test.rb I also get dropped into the debugger
What is strange:
If I head up the call stack in the debugger to the line in the test which has caused the failure – uploader.store!(#file) – and call it directly with (rdb:1) p uploader.store!(#file), it works! By which I mean, the method returns as expected and the file appears in the correct directory.
Thoughts?
I may be doing something really dumb here. It must be something to do with the Rake task loading the Rails environment, right? Am I doubly-including things or something? Is it something to do with the initializer in the Rails environment? (N.B., when I execute store! from the debugger, it stores the file in the location specified in the test, so it is overridding the Rails initializer successfully).
The backtraces
From bundle exec rake test test/uploaders/*_test.rb
# Running tests:
/Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/carrierwave-0.9.0/lib/carrierwave/uploader/store.rb:75: `' (NilClass)
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:926:in `_run_suite'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/parallel_each.rb:71:in `block in _run_suites'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/parallel_each.rb:71:in `map'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/parallel_each.rb:71:in `_run_suites'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:877:in `_run_anything'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:1085:in `run_tests'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:1072:in `block in _run'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:1071:in `each'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:1071:in `_run'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:1059:in `run'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:795:in `block in autorun'
/Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/carrierwave-0.9.0/lib/carrierwave/uploader/store.rb:75:
(rdb:1) where
--> #1 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/carrierwave-0.9.0/lib/carrierwave/uploader/store.rb:75:in `rmdir'
#2 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/carrierwave-0.9.0/lib/carrierwave/uploader/store.rb:61:in `with_callbacks'
#3 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/carrierwave-0.9.0/lib/carrierwave/uploader/store.rb:58:in `store!'
#4 /Users/leo/Projects/PortfolioSite/test/uploaders/image_file_uploader_test.rb:38:in `test_upload_of_file'
#5 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:1258:in `run'
#6 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:933:in `_run_suite'
#7 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/parallel_each.rb:71:in `_run_suites'
#8 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:877:in `_run_anything'
#9 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:1085:in `run_tests'
#10 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:1072:in `_run'
#11 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:1059:in `run'
(rdb:1) up 3
#4 /Users/leo/Projects/PortfolioSite/test/uploaders/image_file_uploader_test.rb:38:in `test_upload_of_file'
(rdb:1) list
[33, 42] in /Users/leo/Projects/PortfolioSite/test/uploaders/image_file_uploader_test.rb
33 end
34
35 # The whole point of this is to upload a file.
36 def test_upload_of_file
37 uploader = ImageFileUploader.new
=> 38 uploader.store!(#file)
39 # Ensure the uploaded file is correct.
40 assert_equal Digest::SHA2.file(#file).hexdigest, Digest::SHA2.file("#{STORE_PATH}/#{FILENAME}").hexdigest
41 end
42
(rdb:1) p uploader.store!(#file)
[:store_versions!]
(rdb:1)
After the call to p uploader.store!(#file), the file has been saved
From zeus test test/uploaders/image_file_uploader_test.rb (this is pretty similar to the above)
/Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/carrierwave-0.9.0/lib/carrierwave/uploader/store.rb:75: `' (NilClass)
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:62:in `loop'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:62:in `go'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:78:in `block (3 levels) in go'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:78:in `fork'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:78:in `block (2 levels) in go'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:73:in `each'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:73:in `block in go'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:62:in `loop'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:62:in `go'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:78:in `block (3 levels) in go'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:78:in `fork'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:78:in `block (2 levels) in go'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:73:in `each'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:73:in `block in go'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:62:in `loop'
from /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:62:in `go'
from -e:1:in `<main>'
/Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/carrierwave-0.9.0/lib/carrierwave/uploader/store.rb:75:
(rdb:1) where
--> #1 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/carrierwave-0.9.0/lib/carrierwave/uploader/store.rb:75:in `rmdir'
#2 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/carrierwave-0.9.0/lib/carrierwave/uploader/store.rb:61:in `with_callbacks'
#3 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/carrierwave-0.9.0/lib/carrierwave/uploader/store.rb:58:in `store!'
#4 /Users/leo/Projects/PortfolioSite/test/uploaders/image_file_uploader_test.rb:38:in `test_upload_of_file'
#5 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:1258:in `run'
#6 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:933:in `_run_suite'
#7 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/parallel_each.rb:71:in `_run_suites'
#8 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:877:in `_run_anything'
#9 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:1085:in `run_tests'
#10 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:1072:in `_run'
#11 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/minitest-4.7.5/lib/minitest/unit.rb:1059:in `run'
#12 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus/m.rb:203:in `execute'
#13 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus/m.rb:121:in `run'
#14 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus/m.rb:106:in `run'
#15 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus/rails.rb:190:in `test'
#16 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:116:in `command'
#17 /Users/leo/.rvm/gems/ruby-2.0.0-p195#portfolio_site/gems/zeus-0.13.3/lib/zeus.rb:80:in `go'
(rdb:1) up 3
#4 /Users/leo/Projects/PortfolioSite/test/uploaders/image_file_uploader_test.rb:38:in `test_upload_of_file'
(rdb:1) list
[33, 42] in /Users/leo/Projects/PortfolioSite/test/uploaders/image_file_uploader_test.rb
33 end
34
35 # The whole point of this is to upload a file.
36 def test_upload_of_file
37 uploader = ImageFileUploader.new
=> 38 uploader.store!(#file)
39 # Ensure the uploaded file is correct.
40 assert_equal Digest::SHA2.file(#file).hexdigest, Digest::SHA2.file("#{STORE_PATH}/#{FILENAME}").hexdigest
41 end
42
(rdb:1) p uploader.store!(#file)
[:store_versions!]
(rdb:1)
The code
Class being tested
class ImageFileUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
version :thumbnail do
process resize_to_fill: [100,100]
end
def extension_white_list
%w(jpg jpeg gif png)
end
end
The test itself
require 'minitest/autorun'
require 'minitest/pride'
require 'minitest/debugger' if ENV['DEBUG']
require 'rmagick'
require 'carrierwave'
require_relative '../../app/uploaders/image_file_uploader'
class ImageFileUploaderTest < MiniTest::Unit::TestCase
# Before any tests run, set up parameters.
FILENAME = 'test_photo_1.jpg'
STORE_DIR = 'tmp/uploads/store'
CACHE_DIR = 'tmp/uploads/cache'
STORE_PATH = File.join __dir__, '..', '..', STORE_DIR
CACHE_PATH = File.join __dir__, '..', '..', CACHE_DIR
# Override the store and cache dirs so we’re not reliant on Rails.
class ::ImageFileUploader
storage :file
store_dir STORE_PATH
cache_dir CACHE_PATH
end
# Before each test runs, set up a file to test with.
def setup
#file = File.new "#{__dir__}/../test_files/#{FILENAME}"
end
# After each test runs, clear the results directory so it doesn't influence other tests.
def teardown
FileUtils.rm_rf STORE_PATH
FileUtils.rm_rf CACHE_PATH
end
# The whole point of this is to upload a file.
def test_upload_of_file
uploader = ImageFileUploader.new
uploader.store!(#file)
# Ensure the uploaded file is correct.
assert_equal Digest::SHA2.file(#file).hexdigest, Digest::SHA2.file("#{STORE_PATH}/#{FILENAME}").hexdigest
end
end
Simple Rake task
require 'rake/testtask'
Rake::TestTask.new('dev:test') do |t|
t.test_files = FileList['test/uploaders/*_test.rb']
end
Rails initializer (N.B. I think the test is isolated from this...)
CarrierWave.configure do |config|
config.storage = :file
# Override the directory where uploaded files will be stored.
config.store_dir = -> do
if model.nil?
"uploads/other/#{Time.now.strftime("%F")}/#{Time.now.strftime("%H-%M-%S")}"
else
# This is a sensible default for uploaders that are meant to be mounted:
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
# Override the directory where temp files will be stored.
config.cache_dir = -> do
# This is a better default because it prevents temp files from becoming public and is more consistent with the Rails directory structure.
Rails.root.join('tmp/uploads')
end
end
Thanks!
I have fixed this, although not through an entirely scientific process as I was changing other things in the code, including the overall Rails environment, as I went along.
The current, working version greatly simplifies the Carrierwave initializer, moving path definition to the uploader, and then monkey-patching those methods in the test.
Annoyingly, the original reason for the initializer-based approach was that custom directories were being picked up for the original image, but not for processed versions. That seems to be working fine now, but how this current code differs from the old one I’m not sure.
Rails initializer
CarrierWave.configure do |config|
config.storage = :file
end
Uploader
class ImageFileUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
version :thumbnail do
process resize_to_fill: [100,100]
end
def extension_white_list
%w(jpg jpeg gif png)
end
def store_dir
if model.nil?
"uploads/other/#{Time.now.strftime("%F")}/#{Time.now.strftime("%H-%M-%S")}"
else
# This is a sensible default for uploaders that are meant to be mounted:
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
def cache_dir
# This is a better default because it prevents temp files from becoming public and is more consistent with the Rails directory structure.
Rails.root.join('tmp/uploads')
end
end
Test
require_relative '../test_helper'
require 'rmagick'
require 'carrierwave'
require_relative '../../app/uploaders/image_file_uploader'
class ImageFileUploaderTest < MiniTest::Unit::TestCase
# Before any tests run, set up parameters.
FILENAME = 'test_photo_1.jpg'
STORE_DIR = 'tmp/uploads/store'
CACHE_DIR = 'tmp/uploads/cache'
STORE_PATH = File.join __dir__, '..', '..', STORE_DIR
CACHE_PATH = File.join __dir__, '..', '..', CACHE_DIR
# Override the store and cache dirs so we’re not reliant on Rails.
class ::ImageFileUploader
storage :file
def store_dir; STORE_PATH; end
def cache_dir; CACHE_PATH; end
end
# Before each test runs, set up a file to test with.
def setup
#file = File.new "#{__dir__}/../test_files/#{FILENAME}"
end
# After each test runs, clear the results directory so it doesn't influence other tests.
def teardown
FileUtils.rm_rf STORE_PATH
FileUtils.rm_rf CACHE_PATH
end
# The whole point of this is to upload a file.
def test_upload_of_file
uploader = ImageFileUploader.new
uploader.store!(#file)
# Ensure the uploaded file is correct.
assert_equal Digest::SHA2.file(#file).hexdigest, Digest::SHA2.file("#{STORE_PATH}/#{FILENAME}").hexdigest
end
# After each test, there is nothing to clean up, as teardown clears the output dir.
def after_tests
end
end
(N.B. The inclusion of test_helper is not relevant to the fix – after I had it working I moved some of the requires up to the helper to DRY up some overlap with other tests.)