Bug 1505859 - Allow rusttests to run when requested without --enable-rust-tests. r=firefox-build-system-reviewers,ted
authorChris Manchester <cmanchester@mozilla.com>
Sat, 10 Nov 2018 14:59:39 +0000
changeset 445914 de5d9f1a6e4ab3345720fe0840295100d953423a
parent 445913 88fb9e85339cb0de54bae6da11cfd8ec390eec46
child 445915 8e4063938d4ba12e1c2c888b902c159534a83202
push id35029
push usercsabou@mozilla.com
push dateTue, 13 Nov 2018 04:22:06 +0000
treeherdermozilla-central@d056f0ff51c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfirefox-build-system-reviewers, ted
bugs1505859
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1505859 - Allow rusttests to run when requested without --enable-rust-tests. r=firefox-build-system-reviewers,ted Differential Revision: https://phabricator.services.mozilla.com/D11514
browser/config/mozconfigs/linux32/rusttests
browser/config/mozconfigs/linux32/rusttests-debug
browser/config/mozconfigs/linux64/rusttests
browser/config/mozconfigs/linux64/rusttests-debug
browser/config/mozconfigs/win32/rusttests
browser/config/mozconfigs/win32/rusttests-debug
browser/config/mozconfigs/win64/rusttests
browser/config/mozconfigs/win64/rusttests-debug
build/moz.configure/rust.configure
config/rules.mk
python/mozbuild/mozbuild/backend/recursivemake.py
python/mozbuild/mozbuild/frontend/emitter.py
--- a/browser/config/mozconfigs/linux32/rusttests
+++ b/browser/config/mozconfigs/linux32/rusttests
@@ -1,10 +1,9 @@
 MOZ_AUTOMATION_BUILD_SYMBOLS=0
 MOZ_AUTOMATION_PACKAGE_TESTS=0
 MOZ_AUTOMATION_L10N_CHECK=0
 
-ac_add_options --enable-rust-tests
 mk_add_options MOZ_MAKE_FLAGS=--output-sync=line
 
 . "$topsrcdir/browser/config/mozconfigs/linux32/nightly"
 
 unset ENABLE_CLANG_PLUGIN
--- a/browser/config/mozconfigs/linux32/rusttests-debug
+++ b/browser/config/mozconfigs/linux32/rusttests-debug
@@ -1,10 +1,9 @@
 MOZ_AUTOMATION_BUILD_SYMBOLS=0
 MOZ_AUTOMATION_PACKAGE_TESTS=0
 MOZ_AUTOMATION_L10N_CHECK=0
 
-ac_add_options --enable-rust-tests
 mk_add_options MOZ_MAKE_FLAGS=--output-sync=line
 
 . "$topsrcdir/browser/config/mozconfigs/linux32/debug"
 
 unset ENABLE_CLANG_PLUGIN
--- a/browser/config/mozconfigs/linux64/rusttests
+++ b/browser/config/mozconfigs/linux64/rusttests
@@ -1,10 +1,9 @@
 MOZ_AUTOMATION_BUILD_SYMBOLS=0
 MOZ_AUTOMATION_PACKAGE_TESTS=0
 MOZ_AUTOMATION_L10N_CHECK=0
 
-ac_add_options --enable-rust-tests
 mk_add_options MOZ_MAKE_FLAGS=--output-sync=line
 
 . "$topsrcdir/browser/config/mozconfigs/linux64/nightly"
 
 unset ENABLE_CLANG_PLUGIN
--- a/browser/config/mozconfigs/linux64/rusttests-debug
+++ b/browser/config/mozconfigs/linux64/rusttests-debug
@@ -1,10 +1,9 @@
 MOZ_AUTOMATION_BUILD_SYMBOLS=0
 MOZ_AUTOMATION_PACKAGE_TESTS=0
 MOZ_AUTOMATION_L10N_CHECK=0
 
-ac_add_options --enable-rust-tests
 mk_add_options MOZ_MAKE_FLAGS=--output-sync=line
 
 . "$topsrcdir/browser/config/mozconfigs/linux64/debug"
 
 unset ENABLE_CLANG_PLUGIN
--- a/browser/config/mozconfigs/win32/rusttests
+++ b/browser/config/mozconfigs/win32/rusttests
@@ -1,7 +1,5 @@
 MOZ_AUTOMATION_BUILD_SYMBOLS=0
 MOZ_AUTOMATION_PACKAGE_TESTS=0
 MOZ_AUTOMATION_L10N_CHECK=0
 
-ac_add_options --enable-rust-tests
-
 . "$topsrcdir/browser/config/mozconfigs/win32/nightly"
--- a/browser/config/mozconfigs/win32/rusttests-debug
+++ b/browser/config/mozconfigs/win32/rusttests-debug
@@ -1,7 +1,5 @@
 MOZ_AUTOMATION_BUILD_SYMBOLS=0
 MOZ_AUTOMATION_PACKAGE_TESTS=0
 MOZ_AUTOMATION_L10N_CHECK=0
 
-ac_add_options --enable-rust-tests
-
 . "$topsrcdir/browser/config/mozconfigs/win32/debug"
--- a/browser/config/mozconfigs/win64/rusttests
+++ b/browser/config/mozconfigs/win64/rusttests
@@ -1,7 +1,5 @@
 MOZ_AUTOMATION_BUILD_SYMBOLS=0
 MOZ_AUTOMATION_PACKAGE_TESTS=0
 MOZ_AUTOMATION_L10N_CHECK=0
 
-ac_add_options --enable-rust-tests
-
 . "$topsrcdir/browser/config/mozconfigs/win64/nightly"
--- a/browser/config/mozconfigs/win64/rusttests-debug
+++ b/browser/config/mozconfigs/win64/rusttests-debug
@@ -1,7 +1,5 @@
 MOZ_AUTOMATION_BUILD_SYMBOLS=0
 MOZ_AUTOMATION_PACKAGE_TESTS=0
 MOZ_AUTOMATION_L10N_CHECK=0
 
-ac_add_options --enable-rust-tests
-
 . "$topsrcdir/browser/config/mozconfigs/win64/debug"
--- a/build/moz.configure/rust.configure
+++ b/build/moz.configure/rust.configure
@@ -267,17 +267,17 @@ add_old_configure_assignment('RUST_TARGE
 js_option(env='RUSTDOC', nargs=1, help='Path to the rustdoc program')
 
 rustdoc = check_prog('RUSTDOC', add_rustup_path('rustdoc'),
                      input='RUSTDOC', allow_missing=True)
 
 # This option is separate from --enable-tests because Rust tests are particularly
 # expensive in terms of compile time (especially for code in libxul).
 option('--enable-rust-tests',
-       help='Enable building of Rust tests, and build-time execution of them')
+       help='Enable building and running of Rust tests during `make check`')
 
 
 @depends('--enable-rust-tests', rustdoc)
 def rust_tests(enable_rust_tests, rustdoc):
     if enable_rust_tests and not rustdoc:
         die('--enable-rust-tests requires rustdoc')
     return bool(enable_rust_tests)
 
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -1069,17 +1069,16 @@ rust_features_flag := --features "$(RUST
 endif
 
 # Don't stop at the first failure. We want to list all failures together.
 rust_test_flag := --no-fail-fast
 
 force-cargo-test-run:
 	$(call RUN_CARGO,test $(cargo_target_flag) $(rust_test_flag) $(rust_test_options) $(rust_features_flag),$(rustflags_override) $(RUSTFLAGS),$(target_cargo_env_vars))
 
-check:: force-cargo-test-run
 endif
 
 ifdef HOST_RUST_LIBRARY_FILE
 
 ifdef HOST_RUST_LIBRARY_FEATURES
 host_rust_features_flag := --features "$(HOST_RUST_LIBRARY_FEATURES)"
 endif
 
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -1181,17 +1181,21 @@ class RecursiveMakeBackend(CommonBackend
                                         'RUST_CARGO_PROGRAMS')
 
     def _process_host_rust_program(self, obj, backend_file):
         self._process_rust_program_base(obj, backend_file,
                                         'HOST_RUST_PROGRAMS',
                                         'HOST_RUST_CARGO_PROGRAMS')
 
     def _process_rust_tests(self, obj, backend_file):
-        self._no_skip['check'].add(backend_file.relobjdir)
+        if obj.config.substs.get('MOZ_RUST_TESTS'):
+            # If --enable-rust-tests has been set, run these as a part of
+            # make check.
+            self._no_skip['check'].add(backend_file.relobjdir)
+            backend_file.write('check:: force-cargo-test-run\n')
         build_target = self._build_target_for_obj(obj)
         self._compile_graph[build_target]
         self._process_non_default_target(obj, 'force-cargo-test-run',
                                          backend_file)
         backend_file.write_once('CARGO_FILE := $(srcdir)/Cargo.toml\n')
         backend_file.write_once('RUST_TESTS := %s\n' % ' '.join(obj.names))
         backend_file.write_once('RUST_TEST_FEATURES := %s\n' % ' '.join(obj.features))
 
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -1300,24 +1300,23 @@ class TreeMetadataEmitter(LoggingMixin):
             yield cls(context, all_files)
 
         for c in components:
             if c.endswith('.manifest'):
                 yield ChromeManifestEntry(context, 'chrome.manifest',
                                           Manifest('components',
                                                    mozpath.basename(c)))
 
-        if self.config.substs.get('MOZ_RUST_TESTS', None):
-            rust_tests = context.get('RUST_TESTS', [])
-            if rust_tests:
-                # TODO: more sophisticated checking of the declared name vs.
-                # contents of the Cargo.toml file.
-                features = context.get('RUST_TEST_FEATURES', [])
+        rust_tests = context.get('RUST_TESTS', [])
+        if rust_tests:
+            # TODO: more sophisticated checking of the declared name vs.
+            # contents of the Cargo.toml file.
+            features = context.get('RUST_TEST_FEATURES', [])
 
-                yield RustTests(context, rust_tests, features)
+            yield RustTests(context, rust_tests, features)
 
         for obj in self._process_test_manifests(context):
             yield obj
 
         for obj in self._process_jar_manifests(context):
             yield obj
 
         computed_as_flags.resolve_flags('MOZBUILD',