Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the way unit tests are built and run #3939

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions mk/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC): \
$$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg test && touch $$@

$$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X): \
$$(DRIVER_CRATE) \
Expand All @@ -47,7 +47,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX): \
$$(TCORELIB_DEFAULT$(1)_T_$(2)_H_$(3)) \
$$(TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) $(BORROWCK) -o $$@ $$< && touch $$@
$$(STAGE$(1)_T_$(2)_H_$(3)) $(BORROWCK) -o $$@ $$< --cfg test && touch $$@

endef

Expand Down Expand Up @@ -110,7 +110,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB): \
$$(CORELIB_CRATE) $$(CORELIB_INPUTS) \
$$(TSREQ$(1)_T_$(2)_H_$(3))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg test && touch $$@

endef

Expand All @@ -134,7 +134,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB): \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
$$(TSREQ$(1)_T_$(2)_H_$(3))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg test && touch $$@

endef

Expand Down
73 changes: 44 additions & 29 deletions mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ FULL_TEST_SREQ$(1)_T_$(2)_H_$(3) = \
$$(TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3))

check-stage$(1)-T-$(2)-H-$(3): \
check-stage$(1)-T-$(2)-H-$(3)-syntax \
check-stage$(1)-T-$(2)-H-$(3)-rustc \
check-stage$(1)-T-$(2)-H-$(3)-core \
check-stage$(1)-T-$(2)-H-$(3)-std \
Expand All @@ -248,6 +249,9 @@ check-stage$(1)-T-$(2)-H-$(3)-core: \
check-stage$(1)-T-$(2)-H-$(3)-std: \
check-stage$(1)-T-$(2)-H-$(3)-std-dummy

check-stage$(1)-T-$(2)-H-$(3)-syntax: \
check-stage$(1)-T-$(2)-H-$(3)-syntax-dummy

check-stage$(1)-T-$(2)-H-$(3)-rustc: \
check-stage$(1)-T-$(2)-H-$(3)-rustc-dummy

Expand Down Expand Up @@ -321,10 +325,11 @@ check-stage$(1)-T-$(2)-H-$(3)-doc-ref: \
# Rules for the core library test runner

$(3)/test/coretest.stage$(1)-$(2)$$(X): \
$$(CORELIB_CRATE) $$(CORELIB_INPUTS) \
$$(SREQ$(1)_T_$(2)_H_$(3))
$$(DRIVER_CRATE) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg core_test

check-stage$(1)-T-$(2)-H-$(3)-core-dummy: \
$(3)/test/coretest.stage$(1)-$(2)$$(X)
Expand All @@ -335,26 +340,38 @@ check-stage$(1)-T-$(2)-H-$(3)-core-dummy: \
# Rules for the standard library test runner

$(3)/test/stdtest.stage$(1)-$(2)$$(X): \
$$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
$$(SREQ$(1)_T_$(2)_H_$(3))
$$(DRIVER_CRATE) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg std_test

check-stage$(1)-T-$(2)-H-$(3)-std-dummy: \
$(3)/test/stdtest.stage$(1)-$(2)$$(X)
@$$(call E, run: $$<)
$$(Q)$$(call CFG_RUN_TEST,$$<,$(2),$(3)) $$(TESTARGS) \
--logfile tmp/check-stage$(1)-T-$(2)-H-$(3)-std.log

# Rules for the syntax test runner

$(3)/test/syntaxtest.stage$(1)-$(2)$$(X): \
$$(DRIVER_CRATE) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg syntax_test

check-stage$(1)-T-$(2)-H-$(3)-syntax-dummy: \
$(3)/test/syntaxtest.stage$(1)-$(2)$$(X)
@$$(call E, run: $$<)
$$(Q)$$(call CFG_RUN_TEST,$$<,$(2),$(3)) $$(TESTARGS) \
--logfile tmp/check-stage$(1)-T-$(2)-H-$(3)-syntax.log

# Rules for the rustc test runner

$(3)/test/rustctest.stage$(1)-$(2)$$(X): \
$$(COMPILER_CRATE) \
$$(COMPILER_INPUTS) \
$$(SREQ$(1)_T_$(2)_H_$(3)) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM)
$$(DRIVER_CRATE) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg rustc_test

check-stage$(1)-T-$(2)-H-$(3)-rustc-dummy: \
$(3)/test/rustctest.stage$(1)-$(2)$$(X)
Expand All @@ -365,13 +382,10 @@ check-stage$(1)-T-$(2)-H-$(3)-rustc-dummy: \
# Rules for the rustdoc test runner

$(3)/test/rustdoctest.stage$(1)-$(2)$$(X): \
$$(RUSTDOC_LIB) $$(RUSTDOC_INPUTS) \
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC)
$$(DRIVER_CRATE) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTDOC)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg rustdoc_test

check-stage$(1)-T-$(2)-H-$(3)-rustdoc-dummy: \
$(3)/test/rustdoctest.stage$(1)-$(2)$$(X)
Expand All @@ -382,13 +396,10 @@ check-stage$(1)-T-$(2)-H-$(3)-rustdoc-dummy: \
# Rules for the rusti test runner

$(3)/test/rustitest.stage$(1)-$(2)$$(X): \
$$(RUSTI_LIB) $$(RUSTI_INPUTS) \
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC)
$$(DRIVER_CRATE) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTI)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg rusti_test

check-stage$(1)-T-$(2)-H-$(3)-rusti-dummy: \
$(3)/test/rustitest.stage$(1)-$(2)$$(X)
Expand All @@ -400,13 +411,10 @@ check-stage$(1)-T-$(2)-H-$(3)-rusti-dummy: \
# Rules for the cargo test runner

$(3)/test/cargotest.stage$(1)-$(2)$$(X): \
$$(CARGO_LIB) $$(CARGO_INPUTS) \
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC)
$$(DRIVER_CRATE) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBCARGO)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg cargo_test

check-stage$(1)-T-$(2)-H-$(3)-cargo-dummy: \
$(3)/test/cargotest.stage$(1)-$(2)$$(X)
Expand Down Expand Up @@ -737,6 +745,9 @@ check-stage$(1)-H-$(2): \
check-stage$(1)-H-$(2)-perf: \
$$(foreach target,$$(CFG_TARGET_TRIPLES), \
check-stage$(1)-T-$$(target)-H-$(2)-perf)
check-stage$(1)-H-$(2)-syntax: \
$$(foreach target,$$(CFG_TARGET_TRIPLES), \
check-stage$(1)-T-$$(target)-H-$(2)-syntax)
check-stage$(1)-H-$(2)-rustc: \
$$(foreach target,$$(CFG_TARGET_TRIPLES), \
check-stage$(1)-T-$$(target)-H-$(2)-rustc)
Expand Down Expand Up @@ -830,6 +841,9 @@ check-stage$(1)-H-all: \
check-stage$(1)-H-all-perf: \
$$(foreach target,$$(CFG_TARGET_TRIPLES), \
check-stage$(1)-H-$$(target)-perf)
check-stage$(1)-H-all-syntax: \
$$(foreach target,$$(CFG_TARGET_TRIPLES), \
check-stage$(1)-H-$$(target)-syntax)
check-stage$(1)-H-all-rustc: \
$$(foreach target,$$(CFG_TARGET_TRIPLES), \
check-stage$(1)-H-$$(target)-rustc)
Expand Down Expand Up @@ -897,6 +911,7 @@ define DEF_CHECK_FOR_STAGE

check-stage$(1): check-stage$(1)-H-$$(CFG_HOST_TRIPLE)
check-stage$(1)-perf: check-stage$(1)-H-$$(CFG_HOST_TRIPLE)-perf
check-stage$(1)-syntax: check-stage$(1)-H-$$(CFG_HOST_TRIPLE)-syntax
check-stage$(1)-rustc: check-stage$(1)-H-$$(CFG_HOST_TRIPLE)-rustc
check-stage$(1)-core: check-stage$(1)-H-$$(CFG_HOST_TRIPLE)-core
check-stage$(1)-std: check-stage$(1)-H-$$(CFG_HOST_TRIPLE)-std
Expand Down
8 changes: 4 additions & 4 deletions mk/tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBFUZZER): \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< --cfg test && touch $$@

$$(TBIN$(1)_T_$(4)_H_$(3))/fuzzer$$(X): \
$$(DRIVER_CRATE) \
Expand Down Expand Up @@ -77,7 +77,7 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBCARGO): \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< --cfg test && touch $$@

$$(TBIN$(1)_T_$(4)_H_$(3))/cargo$$(X): \
$$(DRIVER_CRATE) \
Expand Down Expand Up @@ -106,7 +106,7 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTDOC): \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< --cfg test && touch $$@

$$(TBIN$(1)_T_$(4)_H_$(3))/rustdoc$$(X): \
$$(DRIVER_CRATE) \
Expand Down Expand Up @@ -135,7 +135,7 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTI): \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC)
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< --cfg test && touch $$@

$$(TBIN$(1)_T_$(4)_H_$(3))/rusti$$(X): \
$$(DRIVER_CRATE) \
Expand Down
53 changes: 48 additions & 5 deletions src/driver/driver.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,62 @@
#[no_core];
extern mod core(vers = "0.5");
use core::*;

extern mod std(vers = "0.5");

#[cfg(rustc)]
extern mod self(name = "rustc", vers = "0.5");

#[cfg(rusti)]
extern mod self(name = "rusti", vers = "0.5");

#[cfg(cargo)]
extern mod self(name = "cargo", vers = "0.5");

#[cfg(rustdoc)]
extern mod self(name = "rustdoc", vers = "0.5");

#[cfg(fuzzer)]
extern mod self(name = "fuzzer", vers = "0.5");

#[cfg(rustdoc)]
extern mod self(name = "rustdoc", vers = "0.5");
#[cfg(core_test)]
extern mod self(name = "core", vers = "0.5");

#[cfg(rusti)]
#[cfg(std_test)]
extern mod self(name = "std", vers = "0.5");

#[cfg(syntax_test)]
extern mod self(name = "syntax", vers = "0.5");

#[cfg(rustc_test)]
extern mod self(name = "rustc", vers = "0.5");

#[cfg(rusti_test)]
extern mod self(name = "rusti", vers = "0.5");

#[cfg(rustdoc_test)]
extern mod self(name = "rustdoc", vers = "0.5");

#[cfg(cargo_test)]
extern mod self(name = "cargo", vers = "0.5");

#[cfg(cargo)]
#[cfg(fuzzer)]
#[cfg(rustdoc)]
#[cfg(rusti)]
#[cfg(rustc)]
extern mod self(name = "rustc", vers = "0.5");
fn main() { self::main() }

fn main() { self::main() }
#[cfg(core_test)]
#[cfg(std_test)]
#[cfg(syntax_test)]
#[cfg(rustc_test)]
#[cfg(rusti_test)]
#[cfg(rustdoc_test)]
#[cfg(cargo_test)]
fn main() {
let args = os::args();
// The test vector generated by rustc
let tests = self::__test::tests();
std::test::test_main(args, tests)
}
14 changes: 4 additions & 10 deletions src/libcore/at_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,13 @@ pub pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] {
}
}

#[cfg(notest)]
pub mod traits {
pub impl<T: Copy> @[T] : Add<&[const T],@[T]> {
#[inline(always)]
pure fn add(rhs: & &self/[const T]) -> @[T] {
append(self, (*rhs))
}
pub impl<T: Copy> @[T] : Add<&[const T],@[T]> {
#[inline(always)]
pure fn add(rhs: & &self/[const T]) -> @[T] {
append(self, (*rhs))
}
}

#[cfg(test)]
pub mod traits {}

pub mod raw {
pub type VecRepr = vec::raw::VecRepr;
pub type SliceRepr = vec::raw::SliceRepr;
Expand Down
1 change: 0 additions & 1 deletion src/libcore/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ struct Task {
*/

/// Destroys all managed memory (i.e. @ boxes) held by the current task.
#[cfg(notest)]
#[lang="annihilate"]
pub unsafe fn annihilate() {
use rt::rt_free;
Expand Down
Loading