Skip to content

Commit

Permalink
Added identifiers and update identifier test
Browse files Browse the repository at this point in the history
  • Loading branch information
r59q committed Aug 13, 2023
1 parent 539a304 commit 1581752
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 5 deletions.
5 changes: 5 additions & 0 deletions microbit/v1/source/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* (c) 2023, Center for Computational Thinking and Design at Aarhus University and contributors
*
* SPDX-License-Identifier: MIT
*/
#include "MicroBit.h"
#include "MicroBitUARTService.h"
#include "MicroBitAccelerometerService.h"
Expand Down
6 changes: 6 additions & 0 deletions microbit/v2/source/codebook.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* (c) 2023, Center for Computational Thinking and Design at Aarhus University and contributors
*
* SPDX-License-Identifier: MIT
*/

#include "MicroBit.h"
#ifndef CODEBOOK_H_INCLUDED
#define CODEBOOK_H_INCLUDED
Expand Down
6 changes: 6 additions & 0 deletions microbit/v2/source/helpers.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* (c) 2023, Center for Computational Thinking and Design at Aarhus University and contributors
*
* SPDX-License-Identifier: MIT
*/

#include "MicroBit.h"
#include "codebook.h"
#include "utilities.h"
Expand Down
5 changes: 5 additions & 0 deletions microbit/v2/source/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* (c) 2023, Center for Computational Thinking and Design at Aarhus University and contributors
*
* SPDX-License-Identifier: MIT
*/
#include "MicroBit.h"
#include "MicroBitUARTService.h"
#include "MicroBitAccelerometerService.h"
Expand Down
5 changes: 5 additions & 0 deletions microbit/v2/source/smileys.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* (c) 2023, Center for Computational Thinking and Design at Aarhus University and contributors
*
* SPDX-License-Identifier: MIT
*/
#include "utilities.h"
#ifndef SMILEYS_H_INCLUDED
#define SMILEYS_H_INCLUDED
Expand Down
5 changes: 5 additions & 0 deletions microbit/v2/source/sound.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* (c) 2023, Center for Computational Thinking and Design at Aarhus University and contributors
*
* SPDX-License-Identifier: MIT
*/
#include "MicroBit.h"
#include "utilities.h"
#include "sounds.h"
Expand Down
5 changes: 5 additions & 0 deletions microbit/v2/source/sounds.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* (c) 2023, Center for Computational Thinking and Design at Aarhus University and contributors
*
* SPDX-License-Identifier: MIT
*/
#include "utilities.h"
#ifndef SOUNDS_H_INCLUDED
#define SOUNDS_H_INCLUDED
Expand Down
5 changes: 5 additions & 0 deletions microbit/v2/source/utilities.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* (c) 2023, Center for Computational Thinking and Design at Aarhus University and contributors
*
* SPDX-License-Identifier: MIT
*/
#ifndef UTILITIES_H_INCLUDED
#define UTILITIES_H_INCLUDED

Expand Down
22 changes: 17 additions & 5 deletions src/__tests__/license-identifiers.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
/**
* @jest-environment jsdom
*/
/**
* (c) 2023, Center for Computational Thinking and Design at Aarhus University and contributors
*
* SPDX-License-Identifier: MIT
*/

import fs from 'fs';
import 'jest-expect-message';
import * as path from 'path';

// Place files you wish to ignore by name in here
const ignoredFiles: string[] = [];
const directoriesToScan = ['./src/', './microbit/v2/source/', './microbit/v1/source/']

const licenseIdentifierStringContributors =
'Center for Computational Thinking and Design at Aarhus University and contributors';
Expand Down Expand Up @@ -61,7 +67,7 @@ const filesMissingIdentifier = (files: string[], expects: string[]): string[] =>
for (const expect of expects) {
if (!readFile('./' + files[i], expect)) {
if (!filesWithMissingIdentifier.includes(files[i])) {
filesWithMissingIdentifier.push(files[i]);
filesWithMissingIdentifier.push(files[i]);
}
}
}
Expand All @@ -73,17 +79,23 @@ describe('License identifier tests', () => {
test(
'All files should contain license identifier',
() => {
const flatten = flattenDirectory('./src/');

const flatten = directoriesToScan.reduce(
(acc: any, current) => {
return acc.concat(flattenDirectory(current))
}, []
);

const faultyFiles = filesMissingIdentifier(flatten, [
licenseIdentifierStringContributors,
licenseIdentifierStringSPDX,
]);
expect(
faultyFiles.length,
'Some files do not contain identifier! ' +
faultyFiles
.map(val => `\n \u001b[35m${val} \u001b[0mis missing license identifier`)
.join(),
faultyFiles
.map(val => `\n \u001b[35m${val} \u001b[0mis missing license identifier`)
.join(),
).toEqual(0);
},
60000 * 10,
Expand Down

0 comments on commit 1581752

Please sign in to comment.