|
5 | 5 |
|
6 | 6 | import glob |
7 | 7 | import os |
8 | | -import platform |
9 | 8 | import re |
10 | 9 | import shutil |
11 | 10 | import stat |
12 | | -import tempfile |
13 | 11 | import time |
14 | 12 | from pathlib import Path |
15 | 13 | from subprocess import PIPE, STDOUT |
16 | 14 |
|
17 | | -import common |
18 | 15 | from common import ( |
19 | 16 | EMBUILDER, |
20 | 17 | RunnerCore, |
@@ -180,32 +177,31 @@ def test_aaa_normal(self): |
180 | 177 |
|
181 | 178 | @with_env_modify({'EM_CONFIG': None}) |
182 | 179 | def test_firstrun(self): |
183 | | - default_config = path_from_root('.emscripten') |
| 180 | + default_config = EM_CONFIG |
184 | 181 | output = self.do([EMCC, '-v']) |
185 | 182 | self.assertContained('emcc: warning: config file not found: %s. You can create one by hand or run `emcc --generate-config`' % default_config, output) |
186 | 183 |
|
187 | | - try: |
188 | | - temp_bin = tempfile.mkdtemp() |
| 184 | + temp_bin = os.path.abspath('bin') |
| 185 | + os.mkdir(temp_bin) |
189 | 186 |
|
190 | | - def make_new_executable(name): |
191 | | - utils.write_file(os.path.join(temp_bin, name), '') |
192 | | - make_executable(os.path.join(temp_bin, name)) |
| 187 | + def make_new_executable(name): |
| 188 | + utils.write_file(os.path.join(temp_bin, name), '') |
| 189 | + make_executable(os.path.join(temp_bin, name)) |
193 | 190 |
|
194 | | - make_new_executable('wasm-ld') |
195 | | - make_new_executable('node') |
| 191 | + make_new_executable('wasm-ld') |
| 192 | + make_new_executable('node') |
196 | 193 |
|
197 | | - with env_modify({'PATH': temp_bin + os.pathsep + os.environ['PATH']}): |
198 | | - output = self.do([EMCC, '--generate-config']) |
199 | | - finally: |
200 | | - shutil.rmtree(temp_bin) |
201 | | - config_data = utils.read_file(default_config) |
| 194 | + with env_modify({'PATH': temp_bin + os.pathsep + os.environ['PATH']}): |
| 195 | + output = self.do([EMCC, '--generate-config']) |
| 196 | + |
| 197 | + config_data = utils.read_file(default_config) |
202 | 198 |
|
203 | 199 | self.assertContained('An Emscripten settings file has been generated at:', output) |
204 | 200 | self.assertContained(default_config, output) |
205 | 201 | self.assertContained('It contains our best guesses for the important paths, which are:', output) |
206 | 202 | self.assertContained('LLVM_ROOT', output) |
207 | 203 | self.assertContained('NODE_JS', output) |
208 | | - if platform.system() != 'Windows': |
| 204 | + if not utils.WINDOWS: |
209 | 205 | # os.chmod can't make files executable on Windows |
210 | 206 | self.assertIdentical(temp_bin, re.search("^ *LLVM_ROOT *= (.*)$", output, re.M).group(1)) |
211 | 207 | possible_nodes = [os.path.join(temp_bin, 'node')] |
@@ -524,29 +520,13 @@ def test_emcc_cache_flag(self, use_response_files, relative): |
524 | 520 |
|
525 | 521 | def test_emconfig(self): |
526 | 522 | restore_and_set_up() |
527 | | - |
528 | | - fd, custom_config_filename = tempfile.mkstemp(prefix='.emscripten_config_') |
529 | | - |
530 | | - orig_config = utils.read_file(EM_CONFIG) |
531 | | - |
532 | | - # Move the ~/.emscripten to a custom location. |
533 | | - with os.fdopen(fd, "w") as f: |
534 | | - f.write(get_basic_config()) |
| 523 | + create_file('custom_config', get_basic_config()) |
535 | 524 |
|
536 | 525 | # Make a syntax error in the original config file so that attempting to access it would fail. |
537 | | - utils.write_file(EM_CONFIG, 'asdfasdfasdfasdf\n\'\'\'' + orig_config) |
538 | | - |
539 | | - temp_dir = tempfile.mkdtemp(prefix='emscripten_temp_') |
540 | | - |
541 | | - with common.chdir(temp_dir): |
542 | | - self.run_process([EMCC, '--em-config', custom_config_filename] + MINIMAL_HELLO_WORLD + ['-O2']) |
543 | | - result = self.run_js('a.out.js') |
544 | | - |
545 | | - self.assertContained('hello, world!', result) |
| 526 | + utils.write_file(EM_CONFIG, 'asdfasdfasdfasdf\n') |
546 | 527 |
|
547 | | - # Clean up created temp files. |
548 | | - os.remove(custom_config_filename) |
549 | | - shutil.rmtree(temp_dir) |
| 528 | + self.run_process([EMCC, '--em-config', 'custom_config'] + MINIMAL_HELLO_WORLD) |
| 529 | + self.assertContained('hello, world!', self.run_js('a.out.js')) |
550 | 530 |
|
551 | 531 | def test_emcc_ports(self): |
552 | 532 | restore_and_set_up() |
|
0 commit comments