Skip to content

Commit 856f2fc

Browse files
committed
added new lines.
1 parent 574c69b commit 856f2fc

8 files changed

Lines changed: 115 additions & 4 deletions

File tree

.DS_Store

8 KB
Binary file not shown.

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "module-tools",
3+
"version": "1.0.0",
4+
"description": "Exercises to practice and solidify your understanding of the Tools module of the Software Development Course.",
5+
"main": "index.js",
6+
"directories": {
7+
"test": "tests"
8+
},
9+
"scripts": {
10+
"test": "node tests/runIntegrationTests.js"
11+
},
12+
"keywords": [],
13+
"author": "",
14+
"license": "ISC"
15+
}

shell-pipelines/sort-uniq-head-tail/script-03.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ set -euo pipefail
88
# Basia London 22 9 6
99
# Piotr Glasgow 15 2 25 11 8
1010
# Chandra Birmingham 12 6
11-
sort -k3,3nr scores-table.txt | head -3
11+
sort -k3,3nr scores-table.txt | head -3

shell-pipelines/sort-uniq-head-tail/script-06.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ set -euo pipefail
55
# The input for this script is the events.txt file.
66
# TODO: Write a command to show how many times anyone has entered and exited.
77
# It should be clear from your script's output that there have been 5 Entry events and 4 Exit events.
8-
cut -d' ' -f1 events.txt | sort | uniq -c
8+
cut -d' ' -f1 events.txt | sort | uniq -c

shell-pipelines/tr/script-01.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ set -euo pipefail
66
# The author got feedback that they're using too many exclamation marks (!).
77
#
88
# TODO: Write a command to output the contents of text.txt with every exclamation mark (!) replaced with a full-stop (.).
9-
tr '!' '.' < text.txt
9+
tr '!' '.' < text.txt

shell-pipelines/tr/script-02.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ set -euo pipefail
77
# so every Y should be a Z, and every Z should be a Y!
88
#
99
# TODO: Write a command to output the contents of text.txt with every Y and Z swapped (both upper and lower case).
10-
tr 'YyZz' 'ZzYy' < text.txt
10+
tr 'YyZz' 'ZzYy' < text.txt

sprint-5/.DS_Store

6 KB
Binary file not shown.

tests/runIntegrationTests.js

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
const { execSync } = require("node:child_process");
2+
3+
function runCommand(command) {
4+
return execSync(command, { encoding: "utf-8" }).trim();
5+
}
6+
7+
function normalizeOutput(output) {
8+
return output.replaceAll(/\s+/g, " ").trim();
9+
}
10+
11+
function test(name, systemCommand, nodeCommand) {
12+
try {
13+
const expected = normalizeOutput(runCommand(systemCommand));
14+
const actual = normalizeOutput(runCommand(nodeCommand));
15+
if (expected === actual) {
16+
console.log(`✅ ${name} passed`);
17+
} else {
18+
console.error(`❌ ${name} failed`);
19+
console.error(`Expected: "${expected}"`);
20+
console.error(`Actual: "${actual}"`);
21+
}
22+
} catch (error) {
23+
console.error(`❌ ${name} failed with error: ${error.message}`);
24+
}
25+
}
26+
27+
/* CAT TESTS */
28+
test(
29+
"cat single file",
30+
"cat implement-shell-tools/cat/sample-files/1.txt",
31+
"node implement-shell-tools/cat/cat.js implement-shell-tools/cat/sample-files/1.txt",
32+
);
33+
34+
test(
35+
"cat -n single file",
36+
"cat -n implement-shell-tools/cat/sample-files/1.txt",
37+
"node implement-shell-tools/cat/cat.js -n implement-shell-tools/cat/sample-files/1.txt",
38+
);
39+
40+
test(
41+
"cat multiple files",
42+
"cat implement-shell-tools/cat/sample-files/*.txt",
43+
"node implement-shell-tools/cat/cat.js implement-shell-tools/cat/sample-files/*.txt",
44+
);
45+
46+
test(
47+
"cat -n multiple files",
48+
"cat -n implement-shell-tools/cat/sample-files/*.txt",
49+
"node implement-shell-tools/cat/cat.js -n implement-shell-tools/cat/sample-files/*.txt",
50+
);
51+
52+
test(
53+
"cat -b file",
54+
"cat -b implement-shell-tools/cat/sample-files/3.txt",
55+
"node implement-shell-tools/cat/cat.js -b implement-shell-tools/cat/sample-files/3.txt",
56+
);
57+
58+
/* LS TESTS */
59+
60+
test(
61+
"ls sample-files",
62+
"ls implement-shell-tools/ls/sample-files",
63+
"node implement-shell-tools/ls/ls.js implement-shell-tools/ls/sample-files",
64+
);
65+
66+
/* WC TESTS */
67+
68+
test(
69+
"wc all files",
70+
"wc implement-shell-tools/wc/sample-files/*",
71+
"node implement-shell-tools/wc/wc.js implement-shell-tools/wc/sample-files/*",
72+
);
73+
74+
test(
75+
"wc -l single file",
76+
"wc -l implement-shell-tools/wc/sample-files/3.txt",
77+
"node implement-shell-tools/wc/wc.js -l implement-shell-tools/wc/sample-files/3.txt",
78+
);
79+
80+
test(
81+
"wc -w single file",
82+
"wc -w implement-shell-tools/wc/sample-files/3.txt",
83+
"node implement-shell-tools/wc/wc.js -w implement-shell-tools/wc/sample-files/3.txt",
84+
);
85+
86+
test(
87+
"wc -c single file",
88+
"wc -c implement-shell-tools/wc/sample-files/3.txt",
89+
"node implement-shell-tools/wc/wc.js -c implement-shell-tools/wc/sample-files/3.txt",
90+
);
91+
92+
test(
93+
"wc -l multiple files",
94+
"wc -l implement-shell-tools/wc/sample-files/*",
95+
"node implement-shell-tools/wc/wc.js -l implement-shell-tools/wc/sample-files/*",
96+
);

0 commit comments

Comments
 (0)