Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added copyright identifiers and update identifier test #291

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading