2018-06-13 02:33:56 +00:00
|
|
|
extern crate assert_cmd;
|
|
|
|
extern crate assert_fs;
|
|
|
|
extern crate predicates;
|
|
|
|
|
|
|
|
use std::process;
|
|
|
|
|
|
|
|
use assert_cmd::prelude::*;
|
|
|
|
use assert_fs::prelude::*;
|
|
|
|
use predicates::prelude::*;
|
2016-08-22 20:53:49 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
pub fn invalid_calls() {
|
2018-06-13 02:33:56 +00:00
|
|
|
process::Command::cargo_bin("cobalt")
|
|
|
|
.unwrap()
|
|
|
|
.assert()
|
|
|
|
.failure()
|
|
|
|
.stderr(predicate::str::contains("requires a subcommand").from_utf8());
|
|
|
|
|
|
|
|
process::Command::cargo_bin("cobalt")
|
|
|
|
.unwrap()
|
|
|
|
.arg("--nonexistent-argument")
|
|
|
|
.assert()
|
|
|
|
.failure()
|
|
|
|
.stderr(predicate::str::contains("--nonexistent-argument").from_utf8());
|
2016-08-22 20:53:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2017-05-24 22:57:21 +00:00
|
|
|
pub fn log_levels_trace() {
|
2018-06-13 02:33:56 +00:00
|
|
|
let project_root = assert_fs::TempDir::new().unwrap();
|
|
|
|
project_root
|
|
|
|
.copy_from("tests/fixtures/example", &["*"])
|
2017-05-24 22:57:21 +00:00
|
|
|
.unwrap();
|
2016-08-22 20:53:49 +00:00
|
|
|
|
2018-06-13 02:33:56 +00:00
|
|
|
process::Command::cargo_bin("cobalt")
|
|
|
|
.unwrap()
|
|
|
|
.args(&["build", "-L", "trace"])
|
|
|
|
.current_dir(project_root.path())
|
|
|
|
.assert()
|
|
|
|
.success()
|
|
|
|
.stderr(predicate::str::contains("TRACE").from_utf8())
|
|
|
|
.stderr(predicate::str::contains("DEBUG").from_utf8())
|
|
|
|
.stderr(predicate::str::contains("INFO").from_utf8());
|
|
|
|
|
|
|
|
project_root.close().unwrap();
|
2017-05-24 22:57:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
pub fn log_levels_trace_alias() {
|
2018-06-13 02:33:56 +00:00
|
|
|
let project_root = assert_fs::TempDir::new().unwrap();
|
|
|
|
project_root
|
|
|
|
.copy_from("tests/fixtures/example", &["*"])
|
2017-09-23 23:03:50 +00:00
|
|
|
.unwrap();
|
2017-05-24 22:57:21 +00:00
|
|
|
|
2018-06-13 02:33:56 +00:00
|
|
|
process::Command::cargo_bin("cobalt")
|
|
|
|
.unwrap()
|
|
|
|
.args(&["build", "--trace"])
|
|
|
|
.current_dir(project_root.path())
|
|
|
|
.assert()
|
|
|
|
.success()
|
|
|
|
.stderr(predicate::str::contains("TRACE").from_utf8())
|
|
|
|
.stderr(predicate::str::contains("DEBUG").from_utf8())
|
|
|
|
.stderr(predicate::str::contains("INFO").from_utf8());
|
|
|
|
|
|
|
|
project_root.close().unwrap();
|
2017-05-24 22:57:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
pub fn log_levels_debug() {
|
2018-06-13 02:33:56 +00:00
|
|
|
let project_root = assert_fs::TempDir::new().unwrap();
|
|
|
|
project_root
|
|
|
|
.copy_from("tests/fixtures/example", &["*"])
|
2017-05-24 22:57:21 +00:00
|
|
|
.unwrap();
|
2016-08-22 20:53:49 +00:00
|
|
|
|
2018-06-13 02:33:56 +00:00
|
|
|
process::Command::cargo_bin("cobalt")
|
|
|
|
.unwrap()
|
|
|
|
.args(&["build", "-L", "debug"])
|
|
|
|
.current_dir(project_root.path())
|
|
|
|
.assert()
|
|
|
|
.success()
|
|
|
|
.stderr(predicate::str::contains("[trace]").not().from_utf8())
|
|
|
|
.stderr(predicate::str::contains("[debug]").from_utf8())
|
|
|
|
.stderr(predicate::str::contains("[info]").from_utf8());
|
|
|
|
|
|
|
|
project_root.close().unwrap();
|
2017-05-24 22:57:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
pub fn log_levels_info() {
|
2018-06-13 02:33:56 +00:00
|
|
|
let project_root = assert_fs::TempDir::new().unwrap();
|
|
|
|
project_root
|
|
|
|
.copy_from("tests/fixtures/example", &["*"])
|
2017-09-23 23:03:50 +00:00
|
|
|
.unwrap();
|
2016-08-22 20:53:49 +00:00
|
|
|
|
2018-06-13 02:33:56 +00:00
|
|
|
process::Command::cargo_bin("cobalt")
|
|
|
|
.unwrap()
|
|
|
|
.args(&["build", "-L", "info"])
|
|
|
|
.current_dir(project_root.path())
|
|
|
|
.assert()
|
|
|
|
.success()
|
|
|
|
.stderr(predicate::str::contains("[trace]").not().from_utf8())
|
|
|
|
.stderr(predicate::str::contains("[debug]").not().from_utf8())
|
|
|
|
.stderr(predicate::str::contains("[info]").from_utf8());
|
|
|
|
|
|
|
|
project_root.close().unwrap();
|
2017-05-24 22:57:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
pub fn log_levels_silent() {
|
2018-06-13 02:33:56 +00:00
|
|
|
let project_root = assert_fs::TempDir::new().unwrap();
|
|
|
|
project_root
|
|
|
|
.copy_from("tests/fixtures/example", &["*"])
|
2017-09-23 23:03:50 +00:00
|
|
|
.unwrap();
|
2017-05-24 22:57:21 +00:00
|
|
|
|
2018-06-13 02:33:56 +00:00
|
|
|
process::Command::cargo_bin("cobalt")
|
|
|
|
.unwrap()
|
|
|
|
.args(&["build", "--silent"])
|
|
|
|
.current_dir(project_root.path())
|
|
|
|
.assert()
|
|
|
|
.success()
|
|
|
|
.stdout(predicate::str::is_empty().from_utf8())
|
|
|
|
.stderr(predicate::str::is_empty().from_utf8());
|
|
|
|
|
|
|
|
project_root.close().unwrap();
|
2016-08-22 20:53:49 +00:00
|
|
|
}
|
|
|
|
|
2016-11-07 19:32:20 +00:00
|
|
|
#[test]
|
|
|
|
pub fn clean() {
|
2018-06-13 02:33:56 +00:00
|
|
|
let project_root = assert_fs::TempDir::new().unwrap();
|
|
|
|
project_root
|
|
|
|
.copy_from("tests/fixtures/example", &["*"])
|
2017-09-23 23:03:50 +00:00
|
|
|
.unwrap();
|
2018-06-13 02:33:56 +00:00
|
|
|
let dest = project_root.child("_dest");
|
|
|
|
dest.assert(predicate::path::missing());
|
|
|
|
|
|
|
|
process::Command::cargo_bin("cobalt")
|
|
|
|
.unwrap()
|
|
|
|
.args(&["build", "--trace", "-d", "_dest"])
|
|
|
|
.current_dir(project_root.path())
|
|
|
|
.assert()
|
|
|
|
.success();
|
|
|
|
dest.assert(predicate::path::exists());
|
|
|
|
|
|
|
|
process::Command::cargo_bin("cobalt")
|
|
|
|
.unwrap()
|
|
|
|
.args(&["clean", "--trace", "-d", "_dest"])
|
|
|
|
.current_dir(project_root.path())
|
|
|
|
.assert()
|
|
|
|
.success();
|
|
|
|
dest.assert(predicate::path::missing());
|
|
|
|
|
|
|
|
project_root.close().unwrap();
|
2016-11-07 19:32:20 +00:00
|
|
|
}
|
2017-01-05 23:02:35 +00:00
|
|
|
|
|
|
|
#[test]
|
2018-03-16 20:55:25 +00:00
|
|
|
pub fn clean_empty() {
|
2018-06-13 02:33:56 +00:00
|
|
|
let project_root = assert_fs::TempDir::new().unwrap();
|
|
|
|
project_root
|
|
|
|
.copy_from("tests/fixtures/example", &["*"])
|
2017-09-23 23:03:50 +00:00
|
|
|
.unwrap();
|
2018-06-13 02:33:56 +00:00
|
|
|
let dest = project_root.child("_dest");
|
|
|
|
dest.assert(predicate::path::missing());
|
|
|
|
|
|
|
|
process::Command::cargo_bin("cobalt")
|
|
|
|
.unwrap()
|
|
|
|
.args(&["clean", "--trace", "-d", "_dest"])
|
|
|
|
.current_dir(project_root.path())
|
|
|
|
.assert()
|
|
|
|
.success();
|
|
|
|
dest.assert(predicate::path::missing());
|
|
|
|
|
|
|
|
project_root.close().unwrap();
|
2017-01-05 23:02:35 +00:00
|
|
|
}
|
2017-07-30 00:43:45 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
pub fn init_project_can_build() {
|
2018-06-13 02:33:56 +00:00
|
|
|
let project_root = assert_fs::TempDir::new().unwrap();
|
|
|
|
let dest = project_root.child("_dest");
|
|
|
|
dest.assert(predicate::path::missing());
|
|
|
|
|
|
|
|
process::Command::cargo_bin("cobalt")
|
|
|
|
.unwrap()
|
|
|
|
.args(&["init", "--trace"])
|
|
|
|
.current_dir(project_root.path())
|
|
|
|
.assert()
|
|
|
|
.success();
|
|
|
|
dest.assert(predicate::path::missing());
|
|
|
|
|
|
|
|
process::Command::cargo_bin("cobalt")
|
|
|
|
.unwrap()
|
|
|
|
.args(&["build", "--trace", "-d", "_dest", "--drafts"])
|
|
|
|
.current_dir(project_root.path())
|
|
|
|
.assert()
|
|
|
|
.success();
|
|
|
|
dest.assert(predicate::path::exists());
|
|
|
|
|
|
|
|
project_root.close().unwrap();
|
2017-07-30 00:43:45 +00:00
|
|
|
}
|