Skip to content

Commit

Permalink
ilib-mono: Clean up test files (#41)
Browse files Browse the repository at this point in the history
* Remove the stuff that should be deleted from the .gitignore
* Remove all test files that the unit tests leave over after they run
* Remove left-over debugger; statements
  • Loading branch information
ehoogerbeets authored Dec 13, 2024
1 parent ed6cd16 commit fdf2d01
Show file tree
Hide file tree
Showing 22 changed files with 427 additions and 233 deletions.
65 changes: 0 additions & 65 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,68 +46,3 @@ packages/loctool/build.properties
!packages/loctool/test/ilib-loctool-mock-resource/ilib-loctool-mock-resource-1.0.0.tgz
!packages/loctool/test/ilib-loctool-mock/ilib-loctool-mock-1.0.0.tgz

# TODO: Those files were autogenerated by `turbo run test --force` and should not be here.
# They should be cleanded up instead. This may require tests refactoring and should be addressed in a separate PR.
packages/ilib-lint-common/test/testfiles/test.txt
packages/ilib-lint-common/test/testfiles/test2.txt
packages/ilib-loctool-ghfm/test/testfiles/subproject/de-DE/
packages/ilib-loctool-ghfm/test/testfiles/subproject/fr-FR/
packages/ilib-loctool-ghfm/test/testfiles/test/
packages/ilib-loctool-haml/test/testfiles/ruby/t2.fr-FR.html.haml
packages/ilib-loctool-html/test/testfiles/testfiles/
packages/ilib-loctool-json/test/testfiles/resources/
packages/ilib-loctool-mrkdwn/test/testfiles/js/nostrings_de-DE.js
packages/ilib-loctool-mrkdwn/test/testfiles/js/nostrings_fr-FR.js
packages/ilib-loctool-mrkdwn/test/testfiles/js/test1_de-DE.js
packages/ilib-loctool-mrkdwn/test/testfiles/js/test1_fr-FR.js
packages/ilib-loctool-po/test/testfiles/po/de-DE.po
packages/ilib-loctool-po/test/testfiles/po/fr-FR.po
packages/ilib-loctool-po/test/testfiles/po/no.po
packages/ilib-loctool-po/test/testfiles/po/ru-RU.po
packages/ilib-loctool-po/test/testfiles/po/ru.po
packages/ilib-loctool-po/test/testfiles/resources/
packages/ilib-loctool-xml/test/testfiles/resources/
packages/ilib-loctool-xml/test/testfiles/x/
packages/ilib-tmx/test/testfiles/
packages/loctool/test/test/
packages/loctool/test/testfiles/de-DE/
packages/loctool/test/testfiles/en-GB/
packages/loctool/test/testfiles/es-US/
packages/loctool/test/testfiles/fr-FR/
packages/loctool/test/testfiles/html/CookieFlow.de-DE.html
packages/loctool/test/testfiles/html/CookieFlow.fr-FR.html
packages/loctool/test/testfiles/html/nostrings.de-DE.html
packages/loctool/test/testfiles/html/nostrings.fr-FR.html
packages/loctool/test/testfiles/ja-JP/
packages/loctool/test/testfiles/loctest-extracted.xliff
packages/loctool/test/testfiles/loctest-new-en-GB.xliff
packages/loctool/test/testfiles/md/subproject/de-DE/
packages/loctool/test/testfiles/md/subproject/fr-FR/
packages/loctool/test/testfiles/project2/loctest-extracted.xliff
packages/loctool/test/testfiles/project2/loctest-new-en-GB.xliff
packages/loctool/test/testfiles/project2/loctest-new-es-US.xliff
packages/loctool/test/testfiles/project2/loctest-new-ja-JP.xliff
packages/loctool/test/testfiles/project2/loctest-new-ru-RU.xliff
packages/loctool/test/testfiles/project2/res/values-en/
packages/loctool/test/testfiles/project2/res/values-es/
packages/loctool/test/testfiles/project2/res/values-ja/
packages/loctool/test/testfiles/project2/res/values-ps-rDO/
packages/loctool/test/testfiles/project2/res/values-ru/
packages/loctool/test/testfiles/project3/es-US.mock
packages/loctool/test/testfiles/project3/ja-JP.mock
packages/loctool/test/testfiles/project3/loctest-extracted.xliff
packages/loctool/test/testfiles/project3/loctest-new-es-US.xliff
packages/loctool/test/testfiles/project3/loctest-new-ja-JP.xliff
packages/loctool/test/testfiles/project3/loctest-new-zh-Hans-CN.xliff
packages/loctool/test/testfiles/project3/zh-Hans-CN.mock
packages/loctool/test/testfiles/ruby/t2.fr-FR.html.haml
packages/loctool/test/testfiles/tmpl/CookieFlowTemplate.de-DE.tmpl.html
packages/loctool/test/testfiles/tmpl/CookieFlowTemplate.fr-FR.tmpl.html
packages/loctool/test/testfiles/tmpl/nostrings.de-DE.tmpl.html
packages/loctool/test/testfiles/tmpl/nostrings.fr-FR.tmpl.html
packages/loctool/test/testfiles/xliff20/output-en-US.xliff
packages/loctool/test/testfiles/xliff20/output-ko-KR.xliff
packages/loctool/test/testfiles/xliff20/splitTest/
packages/loctool/test/testfiles/zh-Hans-CN/
packages/tmxtool/test/testfiles/diff.tmx
packages/tmxtool/test/testfiles/merge.tmx
13 changes: 13 additions & 0 deletions packages/ilib-lint-common/test/Serializer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ import SourceFile from '../src/SourceFile.js';

import {describe, expect, test} from '@jest/globals';

function rmrf(path) {
if (fs.existsSync(path)) {
fs.unlinkSync(path);
}
}

afterEach(function() {
[
"test/testfiles/test.txt",
"test/testfiles/test2.txt"
].forEach(rmrf);
});

/**
* @jest-environment node
* @type {import('@jest/types').Global.TestFrameworkGlobals}
Expand Down
6 changes: 3 additions & 3 deletions packages/ilib-lint/test/ResourceXml.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe("testResourceXML", () => {
target: "Diese Zeichenfolge enthält <c0><b>xml</b> Elementer</c0>.",
pathName: "a/b/c.xliff"
});
debugger;

const actual = rule.matchString({
source: resource.getSource(),
target: resource.getTarget(),
Expand Down Expand Up @@ -211,7 +211,7 @@ debugger;
target: "Diese Zeichenfolge enthält <>pxml</>p.",
pathName: "a/b/c.xliff"
});
debugger;
;
const actual = rule.matchString({
source: resource.getSource(),
target: resource.getTarget(),
Expand Down Expand Up @@ -347,7 +347,7 @@ debugger;
resource,
file: "a/b/c.xliff"
});
debugger;

// if the source contains XML tags, the target must too
const expected = [
new Result({
Expand Down
37 changes: 28 additions & 9 deletions packages/ilib-loctool-ghfm/test/MarkdownFile.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MarkdownFile.test.js - test the Markdown file handler object.
*
* Copyright © 2019-2023 Box, Inc.
* Copyright © 2019-2024 Box, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,14 +19,12 @@
var path = require("path");
var fs = require("fs");

if (!MarkdownFile) {
var MarkdownFile = require("../MarkdownFile.js");
var MarkdownFileType = require("../MarkdownFileType.js");
var CustomProject = require("loctool/lib/CustomProject.js");
var ProjectFactory = require("loctool/lib/ProjectFactory.js");
var TranslationSet = require("loctool/lib/TranslationSet.js");
var ResourceString = require("loctool/lib/ResourceString.js");
}
var MarkdownFile = require("../MarkdownFile.js");
var MarkdownFileType = require("../MarkdownFileType.js");
var CustomProject = require("loctool/lib/CustomProject.js");
var ProjectFactory = require("loctool/lib/ProjectFactory.js");
var TranslationSet = require("loctool/lib/TranslationSet.js");
var ResourceString = require("loctool/lib/ResourceString.js");

function diff(a, b) {
var min = Math.min(a.length, b.length);
Expand Down Expand Up @@ -112,6 +110,27 @@ var p3 = new CustomProject({

var mdft3 = new MarkdownFileType(p3);

function rmrf(path) {
if (fs.existsSync(path)) {
fs.unlinkSync(path);
}
}

afterEach(function() {
[
"test/testfiles/subproject/de-DE/notrans.md",
"test/testfiles/subproject/de-DE/notrans2.md",
"test/testfiles/subproject/fr-FR/notrans.md",
"test/testfiles/subproject/fr-FR/notrans2.md",
"test/testfiles/test/testfiles/de-DE/md/nostrings.md",
"test/testfiles/test/testfiles/de-DE/md/test1.md",
"test/testfiles/test/testfiles/de-DE/md/test3.md",
"test/testfiles/test/testfiles/fr-FR/md/nostrings.md",
"test/testfiles/test/testfiles/fr-FR/md/test1.md",
"test/testfiles/test/testfiles/fr-FR/md/test3.md"
].forEach(rmrf);
});

describe("markdown", function() {
test("MarkdownFileConstructor", function() {
expect.assertions(1);
Expand Down
31 changes: 22 additions & 9 deletions packages/ilib-loctool-haml/test/HamlFile.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* HamlFile.test.js - test the Haml file handler object.
*
* Copyright © 2019, 2023 Box, Inc.
* Copyright © 2019, 2023-2024 Box, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,14 +16,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
if (!HamlFile) {
var HamlFile = require("../HamlFile.js");
var HamlFileType = require("../HamlFileType.js");
var CustomProject = require("loctool/lib/CustomProject.js");
var ResourceString = require("loctool/lib/ResourceString.js");
var TranslationSet = require("loctool/lib/TranslationSet.js");
var fs = require("fs");
}
var HamlFile = require("../HamlFile.js");
var HamlFileType = require("../HamlFileType.js");
var CustomProject = require("loctool/lib/CustomProject.js");
var ResourceString = require("loctool/lib/ResourceString.js");
var TranslationSet = require("loctool/lib/TranslationSet.js");

var fs = require("fs");

function diff(a, b) {
if ((!a || !b) && (a || b)) {
console.log("a is " + a + ", b is " + b);
Expand Down Expand Up @@ -55,6 +55,19 @@ var pi = new CustomProject({
identify: true
});
var hft = new HamlFileType(p);

function rmrf(path) {
if (fs.existsSync(path)) {
fs.unlinkSync(path);
}
}

afterEach(function() {
[
".//test/testfiles/ruby/t2.fr-FR.html.haml"
].forEach(rmrf);
});

describe("hamlfile", function() {
test("HamlFileConstructor", function() {
expect.assertions(1);
Expand Down
32 changes: 24 additions & 8 deletions packages/ilib-loctool-html/test/HTMLFile.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* HTMLFile.test.js - test the HTML file handler object.
*
* Copyright © 2018-2019, 2023 Box, Inc.
* Copyright © 2018-2019, 2023-2024 Box, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,13 +18,13 @@
*/
var path = require("path");
var fs = require("fs");
if (!HTMLFile) {
var HTMLFile = require("../HTMLFile.js");
var HTMLFileType = require("../HTMLFileType.js");
var CustomProject = require("loctool/lib/CustomProject.js");
var TranslationSet = require("loctool/lib/TranslationSet.js");
var ResourceString = require("loctool/lib/ResourceString.js");
}

var HTMLFile = require("../HTMLFile.js");
var HTMLFileType = require("../HTMLFileType.js");
var CustomProject = require("loctool/lib/CustomProject.js");
var TranslationSet = require("loctool/lib/TranslationSet.js");
var ResourceString = require("loctool/lib/ResourceString.js");

function diff(a, b) {
var min = Math.min(a.length, b.length);
for (var i = 0; i < min; i++) {
Expand Down Expand Up @@ -55,6 +55,22 @@ var p2 = new CustomProject({
targetDir: "testfiles"
});
var t = new HTMLFileType(p2);

function rmrf(path) {
if (fs.existsSync(path)) {
fs.unlinkSync(path);
}
}

afterEach(function() {
[
"./test/testfiles/testfiles/html/CookieFlow.de-DE.html",
"./test/testfiles/testfiles/html/CookieFlow.fr-FR.html",
"./test/testfiles/testfiles/html/nostrings.de-DE.html",
"./test/testfiles/testfiles/html/nostrings.fr-FR.html"
].forEach(rmrf);
});

describe("htmlfile", function() {
test("HTMLFileConstructor", function() {
expect.assertions(1);
Expand Down
36 changes: 26 additions & 10 deletions packages/ilib-loctool-json/test/JsonFile.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* JsonFile.test.js - test the json file handler object.
*
* Copyright © 2021-2023 Box, Inc.
* Copyright © 2021-2024 Box, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,16 +20,14 @@
var path = require("path");
var fs = require("fs");

if (!JsonFile) {
var JsonFile = require("../JsonFile.js");
var JsonFileType = require("../JsonFileType.js");
var JsonFile = require("../JsonFile.js");
var JsonFileType = require("../JsonFileType.js");

var CustomProject = require("loctool/lib/CustomProject.js");
var TranslationSet = require("loctool/lib/TranslationSet.js");
var ResourceString = require("loctool/lib/ResourceString.js");
var ResourcePlural = require("loctool/lib/ResourcePlural.js");
var ResourceArray = require("loctool/lib/ResourceArray.js");
}
var CustomProject = require("loctool/lib/CustomProject.js");
var TranslationSet = require("loctool/lib/TranslationSet.js");
var ResourceString = require("loctool/lib/ResourceString.js");
var ResourcePlural = require("loctool/lib/ResourcePlural.js");
var ResourceArray = require("loctool/lib/ResourceArray.js");

function diff(a, b) {
var min = Math.min(a.length, b.length);
Expand Down Expand Up @@ -138,6 +136,24 @@ var p2 = new CustomProject({

var t2 = new JsonFileType(p2);

function rmrf(path) {
if (fs.existsSync(path)) {
fs.unlinkSync(path);
}
}

afterEach(function() {
[
"test/testfiles/resources/de/DE/messages.json",
"test/testfiles/resources/de/DE/sparse2.json",
"test/testfiles/resources/fr/FR/messages.json",
"test/testfiles/resources/fr/FR/str.json",
"test/testfiles/resources/fr/FR/sparse2.json",
"test/testfiles/resources/deep_de-DE.json",
"test/testfiles/resources/deep_fr-FR.json"
].forEach(rmrf);
});

describe("jsonfile", function() {
test("JsonFileConstructor", function() {
expect.assertions(1);
Expand Down
29 changes: 21 additions & 8 deletions packages/ilib-loctool-mrkdwn/test/MrkdwnJsFile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
var path = require("path");
var fs = require("fs");

if (!MrkdwnJsFile) {
var MrkdwnJsFile = require("../MrkdwnJsFile.js");
var MrkdwnJsFileType = require("../MrkdwnJsFileType.js");
var CustomProject = require("loctool/lib/CustomProject.js");
var ProjectFactory = require("loctool/lib/ProjectFactory.js");
var TranslationSet = require("loctool/lib/TranslationSet.js");
var ResourceString = require("loctool/lib/ResourceString.js");
}
var MrkdwnJsFile = require("../MrkdwnJsFile.js");
var MrkdwnJsFileType = require("../MrkdwnJsFileType.js");
var CustomProject = require("loctool/lib/CustomProject.js");
var ProjectFactory = require("loctool/lib/ProjectFactory.js");
var TranslationSet = require("loctool/lib/TranslationSet.js");
var ResourceString = require("loctool/lib/ResourceString.js");

var p = new CustomProject({
name: "foo",
Expand Down Expand Up @@ -108,6 +106,21 @@ var p4 = new CustomProject({
});
var mdft4 = new MrkdwnJsFileType(p4);

function rmrf(path) {
if (fs.existsSync(path)) {
fs.unlinkSync(path);
}
}

afterEach(function() {
[
"test/testfiles/js/nostrings_de-DE.js",
"test/testfiles/js/nostrings_fr-FR.js",
"test/testfiles/js/test1_de-DE.js",
"test/testfiles/js/test1_fr-FR.js"
].forEach(rmrf);
});

describe("mrkdwn", function() {
test("MrkdwnJsFileConstructor", function() {
expect.assertions(1);
Expand Down
Loading

0 comments on commit fdf2d01

Please sign in to comment.