From e4b3faca5167aeb77f49b9cfa9140482cd5ebd11 Mon Sep 17 00:00:00 2001 From: Theo Belaire Date: Wed, 15 Apr 2015 10:40:04 -0400 Subject: [PATCH] Added a test for include_bytes! dep info This tests that both include_str! and include_bytes! mark their input file as a dependancy, and it's correctly outputted when you run `rustc --emit dep-info`. --- src/test/run-make/include_bytes_deps/Makefile | 21 +++++++++++++++++++ .../run-make/include_bytes_deps/input.bin | 1 + .../run-make/include_bytes_deps/input.txt | 1 + src/test/run-make/include_bytes_deps/main.rs | 17 +++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 src/test/run-make/include_bytes_deps/Makefile create mode 100644 src/test/run-make/include_bytes_deps/input.bin create mode 100644 src/test/run-make/include_bytes_deps/input.txt create mode 100644 src/test/run-make/include_bytes_deps/main.rs diff --git a/src/test/run-make/include_bytes_deps/Makefile b/src/test/run-make/include_bytes_deps/Makefile new file mode 100644 index 000000000000..0400db412dd2 --- /dev/null +++ b/src/test/run-make/include_bytes_deps/Makefile @@ -0,0 +1,21 @@ +-include ../tools.mk + +# FIXME: ignore freebsd/windows +# on windows `rustc --dep-info` produces Makefile dependency with +# windows native paths (e.g. `c:\path\to\libfoo.a`) +# but msys make seems to fail to recognize such paths, so test fails. +ifneq ($(shell uname),FreeBSD) +ifndef IS_WINDOWS +all: + $(RUSTC) --emit dep-info main.rs + grep "input.txt" $(TMPDIR)/main.d + grep "input.bin" $(TMPDIR)/main.d +else +all: + +endif + +else +all: + +endif diff --git a/src/test/run-make/include_bytes_deps/input.bin b/src/test/run-make/include_bytes_deps/input.bin new file mode 100644 index 000000000000..cd0875583aab --- /dev/null +++ b/src/test/run-make/include_bytes_deps/input.bin @@ -0,0 +1 @@ +Hello world! diff --git a/src/test/run-make/include_bytes_deps/input.txt b/src/test/run-make/include_bytes_deps/input.txt new file mode 100644 index 000000000000..cd0875583aab --- /dev/null +++ b/src/test/run-make/include_bytes_deps/input.txt @@ -0,0 +1 @@ +Hello world! diff --git a/src/test/run-make/include_bytes_deps/main.rs b/src/test/run-make/include_bytes_deps/main.rs new file mode 100644 index 000000000000..579b2a452a11 --- /dev/null +++ b/src/test/run-make/include_bytes_deps/main.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main() { + const INPUT_TXT: &'static str = include_str!("input.txt"); + const INPUT_BIN: &'static [u8] = include_bytes!("input.bin"); + + println!("{}", INPUT_TXT); + println!("{:?}", INPUT_BIN); +}