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.
This commit is contained in:
Tim Chevalier 2013-04-17 13:53:48 -07:00
parent c01c3d9fc6
commit e6c3c371a5
11 changed files with 161 additions and 0 deletions

View File

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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!");
}

View File

@ -0,0 +1,3 @@
pub fn assert_true() {
assert!(true);
}

View File

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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;

View File

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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;

View File

@ -0,0 +1,2 @@
pub fn do_nothing() {
}

View File

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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); } }");
}

View File

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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!");
}

View File

@ -0,0 +1,3 @@
pub fn assert_true() {
assert!(true);
}

View File

@ -0,0 +1,2 @@
pub fn do_nothing() {
}

View File

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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;

View File

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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;