forked from fealebenpae/node-xcode
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpbxWriter.js
More file actions
83 lines (72 loc) · 3.08 KB
/
pbxWriter.js
File metadata and controls
83 lines (72 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
var pbx = require('../lib/pbxProject'),
fs = require('fs'),
myProj;
function testProjectContents(filename, test, expectedFilename) {
var myProj = new pbx(filename);
var content;
if (expectedFilename) {
content = fs.readFileSync(expectedFilename, 'utf-8');
} else {
content = fs.readFileSync(filename, 'utf-8');
}
// normalize tabs vs strings
content = content.replace(/ /g, '\t');
myProj.parse(function (err, projHash) {
var written = myProj.writeSync();
test.equal(content, written);
test.done();
});
}
// for debugging failing tests
function testContentsInDepth(filename, test) {
var myProj = new pbx(filename),
content = fs.readFileSync(filename, 'utf-8');
// normalize tabs vs strings
content = content.replace(/ /g, '\t');
myProj.parse(function (err, projHash) {
var written = myProj.writeSync(),
writtenLines = written.split('\n')
contentLines = content.split('\n')
test.equal(writtenLines.length, contentLines.length);
for (var i=0; i<writtenLines.length; i++) {
test.equal(writtenLines[i], contentLines[i],
'match failed on line ' + (i+1))
}
test.done();
});
}
exports.writeSync = {
'should write out the "hash" test': function (test) {
testProjectContents('test/parser/projects/hash.pbxproj', test);
},
'should write out the "with_array" test': function (test) {
// Special case in that the originating project does not have a trailing comma for all of its array entries.
// This is definitely possibly.
// But when we write/read it out again during testing, the trailing commas are introduced by our library.
testProjectContents('test/parser/projects/with_array.pbxproj', test, 'test/parser/projects/expected/with_array_expected.pbxproj');
},
'should write out the "section" test': function (test) {
testProjectContents('test/parser/projects/section.pbxproj', test);
},
'should write out the "two-sections" test': function (test) {
testProjectContents('test/parser/projects/two-sections.pbxproj', test);
},
'should write out the "section-entries" test': function (test) {
testProjectContents('test/parser/projects/section-entries.pbxproj', test);
},
'should write out the "build-config" test': function (test) {
testProjectContents('test/parser/projects/build-config.pbxproj', test);
},
'should write out the "header-search" test': function (test) {
testProjectContents('test/parser/projects/header-search.pbxproj', test);
},
'should write out the "nested-object" test': function (test) {
testProjectContents('test/parser/projects/nested-object.pbxproj', test);
},
'should write out the "build-files" test': function (test) {
testProjectContents('test/parser/projects/build-files.pbxproj', test);
},
'should write out the "file-references" test': function (test) {
testProjectContents('test/parser/projects/file-references.pbxproj', test);
}
}