Skip to content
This repository has been archived by the owner on Jan 8, 2022. It is now read-only.

Commit

Permalink
Add first integration test
Browse files Browse the repository at this point in the history
The simple test solution is on the ebuild generated for cargo-ebuild
itself. After editing cargo.toml or `cargo update` is necessary to
upadate the test in `test/integration.rs`.
  • Loading branch information
gibix committed Jun 10, 2018
1 parent a0fedb8 commit add0f9e
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target
*.rs.bk
*.ebuild
110 changes: 62 additions & 48 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ log = "0.4.0"
env_logger = "0.5.10"
cargo_metadata = "0.5.4"
toml = "0.4.6"

[dev-dependencies]
assert_cli = "0.6.1"
tempdir = "0.3.7"
131 changes: 131 additions & 0 deletions tests/integration.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
extern crate assert_cli;
extern crate tempdir;

use std::fs::File;
use std::io::prelude::*;
use tempdir::TempDir;

#[test]
fn build() {
let ebuild_name = format!("cargo-ebuild-{}.ebuild", env!("CARGO_PKG_VERSION"));

let build_dir = TempDir::new("build").unwrap();
let build_path = build_dir.path().join(&ebuild_name);

assert_cli::Assert::main_binary()
.with_args(&["build", "-o", build_dir.path().to_str().unwrap()])
.stdout()
.is((format!("Wrote: {}", build_path.display())).as_str())
.unwrap();

let mut build_file = match File::open(build_path) {
Err(why) => panic!("couldn't open generated ebuild: {}", why),
Ok(f) => f,
};

let mut new_ebuild = String::new();
build_file.read_to_string(&mut new_ebuild).unwrap();

assert_eq!(new_ebuild, TEST_EBUILD);
}


const TEST_EBUILD: &str = r#"# Copyright 2017-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Auto-Generated by cargo-ebuild 0.1.6-pre
EAPI=6
CRATES="
aho-corasick-0.6.4
ansi_term-0.11.0
assert_cli-0.6.1
atty-0.2.10
backtrace-0.3.8
backtrace-sys-0.1.23
bitflags-1.0.3
cargo-ebuild-0.1.6-pre
cargo_metadata-0.5.6
cc-1.0.17
cfg-if-0.1.3
clap-2.31.2
colored-1.6.0
difference-2.0.0
dtoa-0.4.2
env_logger-0.5.10
environment-0.1.1
error-chain-0.11.0
failure-0.1.1
failure_derive-0.1.1
fuchsia-zircon-0.3.3
fuchsia-zircon-sys-0.3.3
human-panic-1.0.0
humantime-1.1.1
itoa-0.4.1
lazy_static-0.2.11
lazy_static-1.0.1
libc-0.2.42
log-0.4.2
memchr-2.0.1
os_type-2.0.0
proc-macro2-0.4.6
quick-error-1.2.2
quote-0.3.15
quote-0.6.3
rand-0.4.2
redox_syscall-0.1.40
redox_termios-0.1.1
regex-0.2.11
regex-1.0.0
regex-syntax-0.5.6
regex-syntax-0.6.0
remove_dir_all-0.5.1
rustc-demangle-0.1.8
semver-0.9.0
semver-parser-0.7.0
serde-1.0.66
serde_derive-1.0.66
serde_json-1.0.20
strsim-0.7.0
structopt-0.2.10
structopt-derive-0.2.10
syn-0.11.11
syn-0.14.2
synom-0.11.3
synstructure-0.6.1
tempdir-0.3.7
termcolor-0.3.6
termion-1.5.1
textwrap-0.9.0
thread_local-0.3.5
time-0.1.40
toml-0.4.6
ucd-util-0.1.1
unicode-width-0.1.5
unicode-xid-0.0.4
unicode-xid-0.1.0
unreachable-1.0.0
utf8-ranges-1.0.0
uuid-0.6.5
vec_map-0.8.1
void-1.0.2
winapi-0.3.5
winapi-i686-pc-windows-gnu-0.4.0
winapi-x86_64-pc-windows-gnu-0.4.0
wincolor-0.1.6"
inherit cargo
DESCRIPTION="Generates an ebuild for a package using the in-tree eclasses."
HOMEPAGE="https://github.com/cardoe/cargo-ebuild"
SRC_URI="$(cargo_crate_uris ${CRATES})"
RESTRICT="mirror"
LICENSE="MIT/Apache-2.0" # Update to proper Gentoo format
SLOT="0"
KEYWORDS="~amd64"
IUSE=""
DEPEND=""
RDEPEND=""
"#;

0 comments on commit add0f9e

Please sign in to comment.