Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/ofborg
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3d81ba6d9f92
Choose a base ref
...
head repository: NixOS/ofborg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ee6fb695667c
Choose a head ref
  • 10 commits
  • 11 files changed
  • 2 contributors

Commits on Apr 11, 2018

  1. don't force daemon for tests

    LnL7 committed Apr 11, 2018
    Copy the full SHA
    04d0c2f View commit details
  2. Copy the full SHA
    38d2fe8 View commit details
  3. improve repo clone error

    LnL7 committed Apr 11, 2018
    Copy the full SHA
    c56013f View commit details
  4. Copy the full SHA
    bead09b View commit details
  5. show make-pr.sh output in tests

    LnL7 committed Apr 11, 2018
    Copy the full SHA
    ba17bf5 View commit details
  6. don't set pipefail in make-pr.sh

    It's not used and doesn't work in POSIX shell.
    LnL7 committed Apr 11, 2018
    Copy the full SHA
    6b8268d View commit details
  7. Copy the full SHA
    59279e2 View commit details
  8. add travis config

    LnL7 committed Apr 11, 2018
    Copy the full SHA
    a840237 View commit details
  9. use bash shebangs

    LnL7 committed Apr 11, 2018
    Copy the full SHA
    5d8fcf7 View commit details
  10. Merge pull request #159 from LnL7/test-travis

    add green checkmarks
    grahamc authored Apr 11, 2018
    Copy the full SHA
    ee6fb69 View commit details
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: nix
matrix:
include:
- script:
- nix-shell --run 'cd ofborg && cargo test --lib -- --nocapture'
- nix-shell --run 'cd ofborg && cargo test --lib -- --nocapture' --arg useNix1 true
6 changes: 5 additions & 1 deletion ofborg/src/checkout.rs
Original file line number Diff line number Diff line change
@@ -269,10 +269,14 @@ mod tests {
.current_dir(tpath("./test-srcs"))
.arg(bare)
.arg(co)
.stderr(Stdio::null())
.stdout(Stdio::piped())
.output()
.expect("building the test PR failed");

let stderr = String::from_utf8(output.stderr)
.unwrap_or_else(|err| format!("warning: {}", err));
println!("{}", stderr);

let hash = String::from_utf8(output.stdout).expect("Should just be a hash");
return hash.trim().to_owned();
}
2 changes: 1 addition & 1 deletion ofborg/src/clone.rs
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@ pub trait GitClonable {
if result.success() {
return Ok(());
} else {
return Err(Error::new(ErrorKind::Other, "Failed to clone"));
return Err(Error::new(ErrorKind::Other, format!("Failed to clone from {:?} to {:?}", self.clone_from(), self.clone_to())));
}
}

6 changes: 4 additions & 2 deletions ofborg/src/nix.rs
Original file line number Diff line number Diff line change
@@ -275,7 +275,8 @@ fn lines_from_file(file: File) -> Vec<String> {
#[cfg(test)]
mod tests {
fn nix() -> Nix {
Nix::new("x86_64-linux".to_owned(), "daemon".to_owned(), 1800, None)
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
Nix::new("x86_64-linux".to_owned(), remote, 1800, None)
}

fn noop(operation: Operation) -> Operation {
@@ -502,7 +503,8 @@ mod tests {

#[test]
fn safe_command_custom_gc() {
let nix = Nix::new("x86_64-linux".to_owned(), "daemon".to_owned(), 1800, Some("4g".to_owned()));
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
let nix = Nix::new("x86_64-linux".to_owned(), remote, 1800, Some("4g".to_owned()));

let ret: Result<File, File> =
nix.run(
4 changes: 3 additions & 1 deletion ofborg/src/tasks/build.rs
Original file line number Diff line number Diff line change
@@ -400,6 +400,7 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {
#[cfg(test)]
mod tests {
use super::*;
use std::env;
use std::path::{Path, PathBuf};
use ofborg::message::{Pr, Repo};
use notifyworker::SimpleNotifyWorker;
@@ -408,7 +409,8 @@ mod tests {
use ofborg::test_scratch::TestScratch;

fn nix() -> nix::Nix {
nix::Nix::new("x86_64-linux".to_owned(), "daemon".to_owned(), 1800, None)
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
nix::Nix::new("x86_64-linux".to_owned(), remote, 1800, None)
}

fn tpath(component: &str) -> PathBuf {
4 changes: 3 additions & 1 deletion ofborg/src/tasks/massrebuilder.rs
Original file line number Diff line number Diff line change
@@ -786,6 +786,7 @@ fn parse_commit_messages(messages: Vec<String>) -> Vec<String> {
mod tests {

use super::*;
use std::env;
use std::process::Command;

#[test]
@@ -798,7 +799,8 @@ mod tests {
let nixpkgs = String::from_utf8(output.stdout)
.expect("nixpkgs required");

let nix = nix::Nix::new(String::from("x86_64-linux"), String::from("daemon"), 1200, None);
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
let nix = nix::Nix::new(String::from("x86_64-linux"), remote, 1200, None);
let mut stdenv =
Stdenvs::new(
nix.clone(),
2 changes: 1 addition & 1 deletion ofborg/test-srcs/build-pr/succeed.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

echo "$@"
echo hi
2 changes: 1 addition & 1 deletion ofborg/test-srcs/build/environment.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
#!/usr/bin/env bash

env
2 changes: 1 addition & 1 deletion ofborg/test-srcs/build/succeed.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

echo "$@"
echo hi
42 changes: 15 additions & 27 deletions ofborg/test-srcs/make-pr.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@
#!/bin/sh

set -eux
set -o pipefail
#!/usr/bin/env bash
set -eu

bare=$1
co=$2

(
makepr() {
git init --bare "$bare"
git clone "$bare" "$co"

cp build/* "$co/"
git -C "$co" add .
git -C "$co" commit --no-gpg-sign --author "GrahamCOfBorg <graham+cofborg@example.com>" -m "initial repo commit"
git -C "$co" push origin master

(
cp build/* "$co/"
cd "$co/"
git add .
git commit --no-gpg-sign -m "initial repo commit"
git push origin master
)

(
cp build-pr/* "$co/"
cd "$co/"
git checkout -b my-cool-pr
git add .
git commit --no-gpg-sign -m "check out this cool PR"
git push origin my-cool-pr:refs/pull/1/head

)
) >&2
cp build-pr/* "$co/"
git -C "$co" checkout -b my-cool-pr
git -C "$co" add .
git -C "$co" commit --no-gpg-sign --author "GrahamCOfBorg <graham+cofborg@example.com>" -m "check out this cool PR"
git -C "$co" push origin my-cool-pr:refs/pull/1/head
}

(
cd "$co/"
git rev-parse HEAD
)
makepr >&2
git -C "$co" rev-parse HEAD
13 changes: 7 additions & 6 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
let
pkgs = import ./nix {};

{ pkgs ? import ./nix {}, useNix1 ? true }:

let
inherit (pkgs) stdenv;

phpEnv = stdenv.mkDerivation rec {
@@ -11,12 +10,12 @@ let
nix-prefetch-git
php
phpPackages.composer
nix
git
php
curl
bash
];
]
++ stdenv.lib.optional useNix1 nix;

# HISTFILE = "${src}/.bash_hist";
};
@@ -32,7 +31,9 @@ let
openssl.dev
pkgconfig
git
] ++ (lib.optional stdenv.isDarwin pkgs.darwin.Security);
]
++ stdenv.lib.optional useNix1 nix
++ stdenv.lib.optional stdenv.isDarwin pkgs.darwin.Security;

HISTFILE = "${toString ./.}/.bash_hist";
passthru.phpEnv = phpEnv;