Error on trying to get latest-fastcomp (#590)

I think this is less surprising than continuing to support latest-fastcomp
with the last fastcomp release. That's technically correct - the last release
is 1.40.1, and always will be - but when a user asks for "latest" I think they
want something up to date. Instead, give a clear error that indicates how
they can get an actually up to date build, by using upstream.
diff --git a/emsdk.py b/emsdk.py
index 0b7a4a2..89e9d68 100755
--- a/emsdk.py
+++ b/emsdk.py
@@ -2636,12 +2636,13 @@
   return 1
 
 
-def expand_sdk_name(name):
-  if name in ('latest-fastcomp', 'latest-releases-fastcomp'):
-    # Since we no longer support fastcomp in ToT emscripten, the latest
-    # fastcomp release is fixed at 1.40.1.
-    name = 'sdk-fastcomp-1.40.1'
+def exit_with_fastcomp_error():
+    exit_with_error('The fastcomp backend is not getting new builds or releases. Please use the upstream llvm backend or use an older version than 2.0.0 (such as 1.40.1).')
 
+
+def expand_sdk_name(name):
+  if name in ('latest-fastcomp', 'latest-releases-fastcomp', 'tot-fastcomp', 'sdk-nightly-latest'):
+    exit_with_fastcomp_error()
   if name in ('latest', 'sdk-latest', 'latest-64bit', 'sdk-latest-64bit'):
     # This is effectly the default SDK
     return str(find_latest_releases_sdk('upstream'))
@@ -2651,9 +2652,6 @@
     return str(find_tot_sdk('upstream'))
   elif name == 'tot-upstream':
     return str(find_tot_sdk('upstream'))
-  elif name in ('tot-fastcomp', 'sdk-nightly-latest'):
-    print('error: The fastcomp compiler is not available tot/nightly builds. Please use the upstream llvm backend or use an older version than 2.0.0.')
-    sys.exit(1)
   else:
     # check if it's a release handled by an emscripten-releases version,
     # and if so use that by using the right hash. we support a few notations,
@@ -2670,8 +2668,7 @@
       backend = 'fastcomp'
     fullname = fullname.replace('sdk-', '').replace('-64bit', '').replace('tag-', '')
     if backend == 'fastcomp' and version_key(fullname) >= (2, 0, 0):
-      print('error: The fastcomp compiler is not available in 2.0.0+. Please use the upstream llvm backend or use an older version than 2.0.0.')
-      sys.exit(1)
+      exit_with_fastcomp_error()
     releases_info = load_releases_info()['releases']
     release_hash = get_release_hash(fullname, releases_info)
     if release_hash:
diff --git a/scripts/test.py b/scripts/test.py
index 03a1ace..beee4ac 100755
--- a/scripts/test.py
+++ b/scripts/test.py
@@ -60,10 +60,13 @@
 
 
 def failing_call_with_output(cmd, expected):
-  proc = subprocess.Popen(cmd.split(' '), stdout=subprocess.PIPE, universal_newlines=True)
+  proc = subprocess.Popen(cmd.split(' '), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
   stdout, stderr = proc.communicate()
-  assert proc.returncode, 'call must have failed'
-  assert expected in stdout, 'call did not have the right output'
+  if WINDOWS:
+    print('warning: skipping part of failing_call_with_output() due to error codes not being propagated (see #592)')
+  else:
+    assert proc.returncode, 'call must have failed: ' + str([stdout, "\n========\n", stderr])
+  assert expected in stdout or expected in stderr, 'call did not have the right output'
 
 
 def hack_emsdk(marker, replacement):
@@ -139,9 +142,9 @@
 print('update')
 run_emsdk('update-tags')
 
-print('test latest-releases-fastcomp')
-run_emsdk('install latest-fastcomp')
-run_emsdk('activate latest-fastcomp')
+print('test the last fastcomp release')
+run_emsdk('install 1.40.1-fastcomp')
+run_emsdk('activate 1.40.1-fastcomp')
 
 test_lib_building(fastcomp_emcc, use_asmjs_optimizer=False)
 assert open(emconfig).read().count('LLVM_ROOT') == 1
@@ -151,6 +154,12 @@
 print('verify latest fastcomp version is fixed at 1.40.1')
 checked_call_with_output(fastcomp_emcc + ' -v', '1.40.1', stderr=subprocess.STDOUT)
 
+print('verify that attempting to use newer fastcomp gives an error')
+fastcomp_error = 'The fastcomp backend is not getting new builds or releases. Please use the upstream llvm backend or use an older version than 2.0.0 (such as 1.40.1).'
+failing_call_with_output(emsdk + ' install latest-fastcomp', fastcomp_error)
+failing_call_with_output(emsdk + ' install tot-fastcomp', fastcomp_error)
+failing_call_with_output(emsdk + ' install 2.0.0-fastcomp', fastcomp_error)
+
 print('clear cache')
 check_call(upstream_emcc + ' --clear-cache')
 assert not os.path.exists(LIBC)
@@ -169,7 +178,7 @@
 # TODO; test on latest as well
 check_call(upstream_emcc + ' hello_world.c')
 
-print('test specific release (old)')
+print('test specific release (old, using sdk-* notation)')
 run_emsdk('install sdk-fastcomp-1.38.31-64bit')
 run_emsdk('activate sdk-fastcomp-1.38.31-64bit')