1.39.16 (#503)

Also update precompiled lib tests, for the new cache logic.
diff --git a/emscripten-releases-tags.txt b/emscripten-releases-tags.txt
index 8206654..a416d20 100644
--- a/emscripten-releases-tags.txt
+++ b/emscripten-releases-tags.txt
@@ -1,6 +1,7 @@
 {
-  "latest": "1.39.15",
+  "latest": "1.39.16",
   "releases": {
+    "1.39.16": "ae5001fac3849895a873e422a2a80afc90f3b798",
     "1.39.15": "3880c744c068986d4ee781a61f7b2e820043e11f",
     "1.39.14": "574ad04affb82cc36a32dd89b2a87bea4fb30eba",
     "1.39.13": "7b3cd38017f7c582cfa3ac24a9f12aa6a8dca51f",
diff --git a/scripts/test.py b/scripts/test.py
index e1194d0..914313b 100755
--- a/scripts/test.py
+++ b/scripts/test.py
@@ -11,6 +11,14 @@
 
 assert 'EM_CONFIG' in os.environ, "emsdk should be activated before running this script"
 
+LIBC = os.environ['EM_CACHE'] + '/wasm/libc.a'
+
+# Remove the EM_CACHE environment variable.  It interferes with testing since
+# it would otherwise be fixed for the duration of the script and we expect
+# "emsdk activate" to be able switch between SDKs during the running of this
+# script.
+del os.environ['EM_CACHE']
+
 emconfig = os.environ['EM_CONFIG']
 upstream_emcc = os.path.join('upstream', 'emscripten', 'emcc')
 fastcomp_emcc = os.path.join('fastcomp', 'emscripten', 'emcc')
@@ -80,8 +88,6 @@
 
 TAGS = json.loads(open('emscripten-releases-tags.txt').read())
 
-LIBC = os.environ['EM_CACHE'] + '/wasm/libc.a'
-
 # Tests
 
 print('test .emscripten contents (latest was installed/activated in test.sh)')
@@ -95,31 +101,27 @@
 
 
 def test_lib_building(emcc, use_asmjs_optimizer):
-  def test_build(args, expected=None, unexpected=None):
+  cache_building_messages = ['generating system library: ']
+
+  def test_build(args, expected):
+    if expected:
+      expected = cache_building_messages
+      unexpected = []
+    else:
+      expected = []
+      unexpected = cache_building_messages
     checked_call_with_output(emcc + ' hello_world.c' + args,
                              expected=expected,
                              unexpected=unexpected,
                              stderr=subprocess.STDOUT)
 
-  # by default we ship libc, struct_info, and the asm.js optimizer, as they
-  # are important for various reasons (libc takes a long time to build;
-  # struct_info is a bootstrap product so if the user's setup is broken it's
-  # confusing; the asm.js optimizer is a native application so it needs a
-  # working native local build environment). otherwise we don't ship every
-  # single lib, so some building is expected on first run.
-
-  unexpected_system_libs = ['generating system library: libc.',
-                            'generating system asset: optimizer']
-  if use_asmjs_optimizer:
-    unexpected_system_libs += ['generating system asset: generated_struct_info.json']
-
-  first_time_system_libs = ['generating system library: libdlmalloc.']
-
-  test_build('', expected=first_time_system_libs,
-             unexpected=unexpected_system_libs)
-  test_build(' -O2', unexpected=unexpected_system_libs + first_time_system_libs)
-  test_build(' -s WASM=0', unexpected=unexpected_system_libs + first_time_system_libs)
-  test_build(' -O2 -s WASM=0', unexpected=unexpected_system_libs + first_time_system_libs)
+  # The emsdk ships all system libraries so we don't expect to see any
+  # cache population unless we explicly --clear-cache.
+  test_build('', expected=False)
+  check_call(emcc + ' --clear-cache')
+  test_build(' -O2', expected=True)
+  test_build(' -s WASM=0', expected=False)
+  test_build(' -O2 -s WASM=0', expected=False)
 
 
 def run_emsdk(cmd):