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

Commit

Permalink
add basic integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
gibix committed May 30, 2018
1 parent a9f987a commit 89bc110
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
target
*.rs.bk
*.ebuild
!tests/*.ebuild
119 changes: 119 additions & 0 deletions tests/cargo-ebuild-0.1.6-pre.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# 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
arrayvec-0.4.7
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.4
cc-1.0.17
cfg-if-0.1.3
clap-2.31.2
colored-1.6.0
crossbeam-deque-0.2.0
crossbeam-epoch-0.3.1
crossbeam-utils-0.2.2
difference-2.0.0
dtoa-0.4.2
either-1.5.0
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
glob-0.2.11
human-panic-0.4.0
humantime-1.1.1
itoa-0.4.1
lazy_static-0.2.11
lazy_static-1.0.1
libc-0.2.41
log-0.4.1
memchr-2.0.1
memoffset-0.2.1
nodrop-0.1.12
num_cpus-1.8.0
os_type-2.0.0
proc-macro2-0.3.8
proc-macro2-0.4.4
quick-error-1.2.2
quicli-0.2.0
quote-0.3.15
quote-0.5.2
quote-0.6.3
rand-0.4.2
rayon-0.9.0
rayon-core-1.4.0
redox_syscall-0.1.38
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
scopeguard-0.3.3
semver-0.9.0
semver-parser-0.7.0
serde-1.0.64
serde_derive-1.0.64
serde_json-1.0.19
strsim-0.7.0
structopt-0.2.8
structopt-derive-0.2.8
syn-0.11.11
syn-0.13.11
syn-0.14.1
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.4
winapi-i686-pc-windows-gnu-0.4.0
winapi-x86_64-pc-windows-gnu-0.4.0
wincolor-0.1.6"

CRATES_GIT="
"

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=""

38 changes: 38 additions & 0 deletions tests/integration.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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_dir.path().to_str().unwrap(), "build"])
.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();

let mut test_file = match File::open(format!("tests/{}", ebuild_name)) {
Err(why) => panic!("couldn't open test ebuild: {}", why),
Ok(f) => f,
};

let mut test_ebuild = String::new();
test_file.read_to_string(&mut test_ebuild).unwrap();

assert_eq!(new_ebuild, test_ebuild);
}

0 comments on commit 89bc110

Please sign in to comment.