Skip to content

Commit

Permalink
minimal test cases for project path containing output path
Browse files Browse the repository at this point in the history
  • Loading branch information
edrex committed Mar 18, 2015
1 parent 62dbba5 commit bcbdcbb
Showing 1 changed file with 49 additions and 25 deletions.
74 changes: 49 additions & 25 deletions test/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,25 @@ describe("compile", function(){
done()
})

after(function(done){
exec("rm -rf " + outputPath, function() {
done();
})
})

})

describe("root app", function(){
var projectPath = path.join(__dirname, "apps/compile/root")
var outputPath = path.join(__dirname, "out/compile-root")
describe("root app with .git dir", function(){
var projectPath = path.join(__dirname, "apps","compile","root")
var outputPath = path.join(__dirname, "out","compile-root")
var gitPath = path.join(projectPath, ".git")

// Make at runtime since git refuses to store .git dirs
if (!fs.existsSync(gitPath)) {
fs.mkdirSync(gitPath);
fs.openSync(path.join(gitPath, "foo"), 'a')
}

// Making this at runtime since git refuses to store .git dirs
fs.mkdirSync(path.join(projectPath, ".git"));
fs.openSync(path.join(projectPath, "/.git/foo"), 'a')

it("should compile", function(done){
harp.compile(projectPath, outputPath, function(error){
Expand All @@ -63,41 +73,55 @@ describe("compile", function(){
})
})

it("should not include .git", function(done) {
var rsp = fs.existsSync(path.join(projectPath, ".git/foo"))
it("should not include .git in output", function(done) {
var rsp = fs.existsSync(path.join(projectPath, ".git", "foo"))
rsp.should.be.true

var rsp = fs.existsSync(path.join(outputPath, ".git/foo"))
rsp.should.be.false

var rsp = fs.existsSync(path.join(outputPath, "git"))
var rsp = fs.existsSync(path.join(outputPath, ".git"))
rsp.should.be.false

done()
})

it("should not include www", function(done) {
var rsp = fs.existsSync(path.join(outputPath, "www/foo"))
rsp.should.be.false
after(function(done){
exec("rm -rf " + outputPath + " " + gitPath, function() {
done();
})
})

var rsp = fs.existsSync(path.join(outputPath, "www"))
rsp.should.be.false
})

done()
})
describe("root app with output dir containing .git in project dir", function(){
var projectPath = path.join(__dirname, "apps","compile","root")
var outputPath = path.join(projectPath, "out")
var gitPath = path.join(outputPath, ".git")

after(function(done){
exec("rm -rf " + path.join(projectPath, ".git"), function(){
// Making this at runtime since git refuses to store .git dirs
if (!fs.existsSync(gitPath)) {
fs.mkdirSync(outputPath);
fs.mkdirSync(gitPath);
fs.openSync(path.join(gitPath, "foo"), 'a')
}


it("should compile", function(done){
harp.compile(projectPath, outputPath, function(error){
should.not.exist(error)
done()
})
})

})
it("should not include a copy of the output subpath in output", function(done) {
var rsp = fs.existsSync(path.join(outputPath, "out"))
rsp.should.be.false

done();
})

after(function(done){
exec("rm -rf " + path.join(__dirname, "out"), function(){
done()
after(function(done){
exec("rm -rf " + outputPath, function() {
done();
})
})
})

Expand Down

0 comments on commit bcbdcbb

Please sign in to comment.