Skip to content

Commit

Permalink
Merge pull request #26 from raidiun/duplicate-targets-fix
Browse files Browse the repository at this point in the history
Duplicate targets fix
  • Loading branch information
noseglid authored Sep 7, 2016
2 parents db52715 + 137eb08 commit b51f518
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/make.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export function provideBuilder() {
.split(/[\r\n]{1,2}/)
.filter(line => /^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/.test(line))
.map(targetLine => targetLine.split(':').shift())
.filter( (elem, pos, array) => (array.indexOf(elem) === pos) )
.map(target => ({
exec: 'make',
args: args.concat([ target ]),
Expand Down
7 changes: 7 additions & 0 deletions spec/Makefile.withduplicates
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
all:
@echo "Building all"

duplicated: all

duplicated:
@echo "Building duplicated"
16 changes: 16 additions & 0 deletions spec/build-make-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ describe('make', () => {
});
});

describe('when makefile contains duplicate targets', () => {
beforeEach(() => {
fs.writeFileSync(directory + 'Makefile', fs.readFileSync(`${__dirname}/Makefile.withduplicates`));
});
it('should yield only a single target for each duplicate entry', () => {
atom.config.set('build-make.useMake', false); // Not using make to avoid extracting Makefile as pseudotarget
waitsForPromise(() => {
expect(builder.isEligible(directory)).toBe(true);
return Promise.resolve(builder.settings(directory)).then((settings) => {
const targetNames = settings.map(s => s.name).sort();
expect(targetNames).toEqual([ 'GNU Make: default (no target)', 'GNU Make: all', 'GNU Make: duplicated' ].sort());
});
});
});
});

describe('when makefile exists but make can not run', () => {
const originalPath = process.env.PATH;
beforeEach(() => {
Expand Down

0 comments on commit b51f518

Please sign in to comment.