about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-02-24 02:40:16 +0000
committerbors <bors@rust-lang.org>2017-02-24 02:40:16 +0000
commit674af8c7f593bf69fd2f5edbd718d4b6100656ef (patch)
treece7dc85a176532110386593d98a33235b92b6528 /src/test
parent413a975e31584d1e22d158a70c6d3073b991a618 (diff)
parent40aaa65734d72b7aabda3cd0925b0119fb6d5a0a (diff)
downloadrust-674af8c7f593bf69fd2f5edbd718d4b6100656ef.tar.gz
rust-674af8c7f593bf69fd2f5edbd718d4b6100656ef.zip
Auto merge of #39851 - alexcrichton:verify-unstable, r=brson
test: Verify all sysroot crates are unstable

As we continue to add more crates to the compiler and use them to implement
various features we want to be sure we're not accidentally expanding the API
surface area of the compiler! To that end this commit adds a new `run-make` test
which will attempt to `extern crate foo` all crates in the sysroot, verifying
that they're all unstable.

This commit discovered that the `std_shim` and `test_shim` crates were
accidentally stable and fixes the situation by deleting those shims. The shims
are no longer necessary due to changes in Cargo that have happened since they
were originally incepted.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-make/sysroot-crates-are-unstable/Makefile34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/run-make/sysroot-crates-are-unstable/Makefile b/src/test/run-make/sysroot-crates-are-unstable/Makefile
new file mode 100644
index 00000000000..2bdc76e01db
--- /dev/null
+++ b/src/test/run-make/sysroot-crates-are-unstable/Makefile
@@ -0,0 +1,34 @@
+-include ../tools.mk
+
+# This is a whitelist of crates which are stable, we don't check for the
+# instability of these crates as they're all stable!
+STABLE_CRATES := \
+	std \
+	core \
+	proc_macro \
+	rsbegin.o \
+	rsend.o \
+	dllcrt2.o \
+	crt2.o
+
+# Generate a list of all crates in the sysroot. To do this we list all files in
+# rustc's sysroot, look at the filename, strip everything after the `-`, and
+# strip the leading `lib` (if present)
+SYSROOT := $(shell $(RUSTC) --print sysroot)
+LIBS := $(wildcard $(SYSROOT)/lib/rustlib/$(TARGET)/lib/*)
+LIBS := $(foreach lib,$(LIBS),$(notdir $(lib)))
+LIBS := $(foreach lib,$(LIBS),$(word 1,$(subst -, ,$(lib))))
+LIBS := $(foreach lib,$(LIBS),$(patsubst lib%,%,$(lib)))
+LIBS := $(filter-out $(STABLE_CRATES),$(LIBS))
+
+all: $(foreach lib,$(LIBS),check-crate-$(lib)-is-unstable)
+
+check-crate-%-is-unstable:
+	@echo verifying $* is an unstable crate
+	@echo 'extern crate $*;' | \
+		$(RUSTC) - --crate-type rlib 2>&1 | cat > $(TMPDIR)/$*; \
+		true
+	@grep -q 'use of unstable library feature' $(TMPDIR)/$* || \
+		(echo crate $* is not unstable && \
+		cat $(TMPDIR)/$* && \
+		false)