From e6c3c371a554de6079c1c0b27885b8792431e516 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Wed, 17 Apr 2013 13:53:48 -0700 Subject: [PATCH] rustpkg: Add a few tests There's no test runner for rustpkg yet; just sketching out a few basic test scenarios. pass/ contains packages that should compile successfully, whereas fail/ contains packages that should fail to build. --- .../fail/no-inferred-crates/zzyzx.rs | 22 +++++++++++++++++ .../testsuite/pass/fancy-lib/bar.rs | 3 +++ .../testsuite/pass/fancy-lib/fancy-lib.rc | 24 +++++++++++++++++++ .../testsuite/pass/fancy-lib/fancy-lib.rs | 24 +++++++++++++++++++ .../testsuite/pass/fancy-lib/foo.rs | 2 ++ .../testsuite/pass/fancy-lib/pkg.rs | 17 +++++++++++++ .../testsuite/pass/hello-world/main.rs | 22 +++++++++++++++++ .../testsuite/pass/simple-lib/bar.rs | 3 +++ .../testsuite/pass/simple-lib/foo.rs | 2 ++ .../testsuite/pass/simple-lib/lib.rs | 21 ++++++++++++++++ .../testsuite/pass/simple-lib/simple-lib.rc | 21 ++++++++++++++++ 11 files changed, 161 insertions(+) create mode 100644 src/librustpkg/testsuite/fail/no-inferred-crates/zzyzx.rs create mode 100644 src/librustpkg/testsuite/pass/fancy-lib/bar.rs create mode 100644 src/librustpkg/testsuite/pass/fancy-lib/fancy-lib.rc create mode 100644 src/librustpkg/testsuite/pass/fancy-lib/fancy-lib.rs create mode 100644 src/librustpkg/testsuite/pass/fancy-lib/foo.rs create mode 100644 src/librustpkg/testsuite/pass/fancy-lib/pkg.rs create mode 100644 src/librustpkg/testsuite/pass/hello-world/main.rs create mode 100644 src/librustpkg/testsuite/pass/simple-lib/bar.rs create mode 100644 src/librustpkg/testsuite/pass/simple-lib/foo.rs create mode 100644 src/librustpkg/testsuite/pass/simple-lib/lib.rs create mode 100644 src/librustpkg/testsuite/pass/simple-lib/simple-lib.rc diff --git a/src/librustpkg/testsuite/fail/no-inferred-crates/zzyzx.rs b/src/librustpkg/testsuite/fail/no-inferred-crates/zzyzx.rs new file mode 100644 index 00000000000..c9c1f00fb08 --- /dev/null +++ b/src/librustpkg/testsuite/fail/no-inferred-crates/zzyzx.rs @@ -0,0 +1,22 @@ +// Copyright 2013 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. + +/* +The test runner should check that, after `rustpkg build hello-world`: + * testsuite/hello-world/build/ exists + * testsuite/hello-world/build/ contains an executable named hello-world + * testsuite/hello-world/build/ does not contain a library +*/ + +use core::io; + +fn main() { + io::println(~"Hello world!"); +} diff --git a/src/librustpkg/testsuite/pass/fancy-lib/bar.rs b/src/librustpkg/testsuite/pass/fancy-lib/bar.rs new file mode 100644 index 00000000000..e300c2a3295 --- /dev/null +++ b/src/librustpkg/testsuite/pass/fancy-lib/bar.rs @@ -0,0 +1,3 @@ +pub fn assert_true() { + assert!(true); +} diff --git a/src/librustpkg/testsuite/pass/fancy-lib/fancy-lib.rc b/src/librustpkg/testsuite/pass/fancy-lib/fancy-lib.rc new file mode 100644 index 00000000000..55261a82098 --- /dev/null +++ b/src/librustpkg/testsuite/pass/fancy-lib/fancy-lib.rc @@ -0,0 +1,24 @@ +// Copyright 2013 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. + +/* +The test runner should check that, after `rustpkg build fancy-lib`: + * testsuite/fancy-lib/build/ exists + * testsuite/fancy-lib/build/ contains a file called generated.rs + * testsuite/fancy-lib/build/ contains a library named libfancy_lib + * testsuite/fancy-lib/build/ does not contain an executable + * +*/ + +extern mod std; + +pub mod foo; +pub mod bar; +#[path = "build/generated.rs"] pub mod generated; diff --git a/src/librustpkg/testsuite/pass/fancy-lib/fancy-lib.rs b/src/librustpkg/testsuite/pass/fancy-lib/fancy-lib.rs new file mode 100644 index 00000000000..16c384ad8b8 --- /dev/null +++ b/src/librustpkg/testsuite/pass/fancy-lib/fancy-lib.rs @@ -0,0 +1,24 @@ +// Copyright 2013 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. + +/* +The test runner should check that, after `rustpkg build fancy-lib`: + * testsuite/fancy-lib/build/ exists + * testsuite/fancy-lib/build/ contains a file called generated.rs + * testsuite/fancy-lib/build/ contains a library named libfancy_lib + * testsuite/fancy-lib/build/ does not contain an executable + * +*/ + +extern mod std; + +pub mod foo; +pub mod bar; +pub mod generated; diff --git a/src/librustpkg/testsuite/pass/fancy-lib/foo.rs b/src/librustpkg/testsuite/pass/fancy-lib/foo.rs new file mode 100644 index 00000000000..4b3f3923d05 --- /dev/null +++ b/src/librustpkg/testsuite/pass/fancy-lib/foo.rs @@ -0,0 +1,2 @@ +pub fn do_nothing() { +} \ No newline at end of file diff --git a/src/librustpkg/testsuite/pass/fancy-lib/pkg.rs b/src/librustpkg/testsuite/pass/fancy-lib/pkg.rs new file mode 100644 index 00000000000..6d3495f2b28 --- /dev/null +++ b/src/librustpkg/testsuite/pass/fancy-lib/pkg.rs @@ -0,0 +1,17 @@ +// Copyright 2013 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() { + let cwd = os::getcwd(); + debug!("cwd = %s", cwd.to_str()); + let file = io::file_writer(&Path(~"fancy-lib/build/generated.rs"), + [io::Create]).get(); + file.write_str("pub fn wheeeee() { for [1, 2, 3].each() |_| { assert!(true); } }"); +} \ No newline at end of file diff --git a/src/librustpkg/testsuite/pass/hello-world/main.rs b/src/librustpkg/testsuite/pass/hello-world/main.rs new file mode 100644 index 00000000000..c9c1f00fb08 --- /dev/null +++ b/src/librustpkg/testsuite/pass/hello-world/main.rs @@ -0,0 +1,22 @@ +// Copyright 2013 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. + +/* +The test runner should check that, after `rustpkg build hello-world`: + * testsuite/hello-world/build/ exists + * testsuite/hello-world/build/ contains an executable named hello-world + * testsuite/hello-world/build/ does not contain a library +*/ + +use core::io; + +fn main() { + io::println(~"Hello world!"); +} diff --git a/src/librustpkg/testsuite/pass/simple-lib/bar.rs b/src/librustpkg/testsuite/pass/simple-lib/bar.rs new file mode 100644 index 00000000000..e300c2a3295 --- /dev/null +++ b/src/librustpkg/testsuite/pass/simple-lib/bar.rs @@ -0,0 +1,3 @@ +pub fn assert_true() { + assert!(true); +} diff --git a/src/librustpkg/testsuite/pass/simple-lib/foo.rs b/src/librustpkg/testsuite/pass/simple-lib/foo.rs new file mode 100644 index 00000000000..4b3f3923d05 --- /dev/null +++ b/src/librustpkg/testsuite/pass/simple-lib/foo.rs @@ -0,0 +1,2 @@ +pub fn do_nothing() { +} \ No newline at end of file diff --git a/src/librustpkg/testsuite/pass/simple-lib/lib.rs b/src/librustpkg/testsuite/pass/simple-lib/lib.rs new file mode 100644 index 00000000000..1cdca6cdd5d --- /dev/null +++ b/src/librustpkg/testsuite/pass/simple-lib/lib.rs @@ -0,0 +1,21 @@ +// Copyright 2013 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. + +/* +The test runner should check that, after `rustpkg build simple-lib`: + * testsuite/simple-lib/build/ exists + * testsuite/simple-lib/build/ contains a library named libsimple_lib + * testsuite/simple-lib/build/ does not contain an executable +*/ + +extern mod std; + +pub mod foo; +pub mod bar; diff --git a/src/librustpkg/testsuite/pass/simple-lib/simple-lib.rc b/src/librustpkg/testsuite/pass/simple-lib/simple-lib.rc new file mode 100644 index 00000000000..1cdca6cdd5d --- /dev/null +++ b/src/librustpkg/testsuite/pass/simple-lib/simple-lib.rc @@ -0,0 +1,21 @@ +// Copyright 2013 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. + +/* +The test runner should check that, after `rustpkg build simple-lib`: + * testsuite/simple-lib/build/ exists + * testsuite/simple-lib/build/ contains a library named libsimple_lib + * testsuite/simple-lib/build/ does not contain an executable +*/ + +extern mod std; + +pub mod foo; +pub mod bar;