Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
eater
Search
Yosuke Furukawa
PRO
April 26, 2016
Programming
2
1.3k
eater
node 学園付属小学校の2回目で話した eater の話です。
Yosuke Furukawa
PRO
April 26, 2016
Tweet
Share
More Decks by Yosuke Furukawa
See All by Yosuke Furukawa
Node.js, Deno, Bun 最新動向とその所感について
yosuke_furukawa
PRO
6
3k
Welcome JSConf.jp 2024
yosuke_furukawa
PRO
1
3.9k
tc39 x jsconf.jp Panel Discussion 2024
yosuke_furukawa
PRO
0
200
Removing Corepack
yosuke_furukawa
PRO
9
1.5k
JavaScript Runtime とはなにか
yosuke_furukawa
PRO
15
2.7k
Strip Types と Storage
yosuke_furukawa
PRO
4
380
Module Harmony について
yosuke_furukawa
PRO
3
1.7k
LTのやり方
yosuke_furukawa
PRO
16
2.5k
AppRouter Panel Talk
yosuke_furukawa
PRO
3
770
Other Decks in Programming
See All in Programming
マルチアカウント環境での、そこまでがんばらない RI/SP 運用設計
wa6sn
0
610
아직도 SOLID 를 '글'로만 알고 계신가요?
sh1mj1
0
360
Day0 初心者向けワークショップ実践!ソフトウェアテストの第一歩
satohiroyuki
0
440
Devinのメモリ活用の学びを自社サービスにどう組み込むか?
itarutomy
0
1.7k
私の愛したLaravel 〜レールを超えたその先へ〜
kentaroutakeda
12
3.6k
複数ドメインに散らばってしまった画像…! 運用中のPHPアプリに後からCDNを導入する…!
suguruooki
0
440
アーキテクトと美学 / Architecture and Aesthetics
nrslib
12
3.1k
DomainException と Result 型で作る型安全なエラーハンドリング
karszawa
0
360
複雑なフォームと複雑な状態管理にどう向き合うか / #newt_techtalk vol. 15
izumin5210
4
3.3k
パスキーのすべて / 20250324 iddance Lesson.5
kuralab
0
130
AIコードエディタの基盤となるLLMのFlutter性能評価
alquist4121
0
100
eBPF Updates (March 2025)
kentatada
0
130
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.7k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
51
2.4k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.2k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
102
18k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
118
51k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7.1k
Designing for Performance
lara
606
69k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
500
The Invisible Side of Design
smashingmag
299
50k
RailsConf 2023
tenderlove
29
1k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
Transcript
Eater @yosuke_furukawa
@yosuke_furukawa
Hello, Noders. This is Full-time Papa committer
None
child_process.spawn()
None
Node Quiz
Quiz: child_process API ͷԼهͷ ҧ͍ԿͰ͠ΐ͏ 1. exec 2. spawn 3.
fork
A: spawn ͕Ұ൪ϩʔϨϕϧ exec/fork spawn ͷ wrapper
A: exec callback Ͱड͚Δɺ fork JavaScript ͷίʔυ Λ
Node.js ͱͯ͠࠶࣮ߦ͢Δ
child_process.spawn const spawn = require('child_process').spawn; const ls = spawn('ls', [‘-al']);
ls.stdout.on('data', (data) => { console.log(data); }); ls.stderr.on('data', (data) => { console.log(data); }); ls.on('exit', (code) => { if (code !== 0) console.error(`Error occurred`); });
child_process.exec const exec = require('child_process').exec; exec(‘ls -al‘, (err, stdout, stderr)
=> { console.log(`${stdout}`); console.error(`${stderr}`); if (error !== null) { console.error(`Error occurred`); } });
child_process.fork const fork = require('child_process').fork; const ls = fork(‘ls.js’); ls.stdout.on('data',
(data) => { console.log(data); }); ls.stderr.on('data', (data) => { console.log(data); }); ls.on('exit', (code) => { if (code !== 0) console.error(`Error occurred`); });
spawn > exec ͜ͷॱͰ simple exec > spawn ͜ͷॱͰ easy
spawn > fork ͜ͷॱͰ simple fork > spawn ͜ͷॱͰ easy
Easy / Simple ͷҧ͍
None
Simple !== Easy
Simple is “୯७” ٬؍తɺҰͭͷࣄ͔͠͠ͳ͍
Easy is “؆୯” ओ؍తɺ”୭͔”ʹͱͬͯ؆୯ “୭ʹͱͬͯ؆୯” ଘࡏ͠ͳ͍
ॳ৺ऀ͕ؕΓ͕ͪͳࣄɿ Easy ͷݴ༿ʹὃ͞Ε͕ͪ ୭ʹͱͬͯEasy ͳΜͯ͋Γ ͑ͳ͍
ॳ৺ऀ͕ؕΓ͕ͪͳࣄɿ Simple ͱ Easy Λࠞಉ͍ͯ͠ Δʹࠔ͞Ε͕ͪ
Eater
Eater is *Ea*sy *t*est runn*er*
Eater has one simple rule If test file outputs `stderr`
message, the test failed.
Easy => ୭ʹͱͬͯʁ `node` ͔͠Βͳ͍Α͏ͳਓ mocha/jestͷࡉ͔͍ߏจΛ֮ ͑ͯͳͯ͘ɺnode ίϚϯυ ͰεΫϦϓτͱ࣮ͯ͠ߦ͢Δ ͚ͩͰΠφϑͳਓ
Eaterͷtest script `node` command Ͱ࣮ߦͰ͖Δ
Easy => ୭ʹͱͬͯʁ mock/spyΛଟ༻͢Δ͚Ͳɺ mock/spyͷ։์࿙ΕΛΕ ͕ͪͳਓʹͱͬͯ
EaterͷtestҰͭҰ͕ͭผϓ ϩηεͰ࣮ߦ͞ΕΔ
mockΛ։์͠ͳͯ͘OK // you don’t need to fix mock/spy console.log =>
(message) { assert(message.match(/Foo Bar/)); }; const mockDate = new Date(2016, 3, 9); Date.now = () => { return mockDate.valueOf(); }; process.exit => (exitcode) { assert(exitcode === 1); };
͔͠ϓϩηείΞͰ ಄ଧͪʹͳΔ eater ——procs 4 ※procs optionͰՄม
Eater DEMO https://github.com/yosuke- furukawa/eater-demo
Happy Eater https://github.com/yosuke- furukawa/eater